Skip to content

Commit

Permalink
rough draft of show pages
Browse files Browse the repository at this point in the history
  • Loading branch information
evdevdev committed Aug 28, 2024
1 parent b5a98f5 commit 1fda608
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/action_prompt/previews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ def index
end

def show
@preview = ActionPrompt::Preview.find(params[:preview])
end
end
4 changes: 2 additions & 2 deletions app/views/action_prompt/previews/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<% if @previews.any? %>
<% @previews.each do |preview| %>
<h3><%= preview.preview_name %></h3>
<h3><%= preview.preview_name.titleize %></h3>
<% preview.prompts.each do |prompt| %>
<p><%= link_to prompt, "/action_prompt/preview/#{prompt}" %></p>
<p><%= link_to prompt, "/action_prompt/preview/#{preview.preview_name}/#{prompt}" %></p>
<% end %>
<% end %>
<% else %>
Expand Down
4 changes: 4 additions & 0 deletions lib/action_prompt/preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def preview_name
def prompts
public_instance_methods(false).map(&:to_s).sort
end

def find(preview_name)
all.find { |p| p.preview_name == preview_name }
end
end
end
end

0 comments on commit 1fda608

Please sign in to comment.