-
-
Save px-amaac/d137d262a78acb156018 to your computer and use it in GitHub Desktop.
_step.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if step.title != nil %> | |
<p> | |
<%= step.title %> | |
<%= step.problem %> | |
<%= step.solution %> | |
<%= link_to 'Show', tutorial_step_path(tutorial_id, step) %> | |
<%= link_to 'Destroy', tutorial_step_path(tutorial_id, step), method: :delete, data: { confirm: 'Are you sure?' } %> | |
</p> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render partial: 'step', collection: @steps, :locals => { :tutorial_id => @tutorial.id } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StepsController < ApplicationController | |
before_action :correct_user, only: [:create, :destroy, :show] | |
def show | |
@step = @tutorial.steps.find_by(id: params[:id]) | |
#I have also tried @step = Step.find(params[:id]) | |
end | |
private | |
def correct_user | |
@tutorial = current_user.tutorials.find_by(id: params[:tutorial_id]) | |
redirect_to root_url if @tutorial.nil? | |
end | |
def step_params | |
params.require(:step).permit(:title, :problem, :solution) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render 'tutorials/step', :locals => { :tutorial_id => @tutorial.id } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- not sure how to define :step for the partial to use it. --> | |
<%= render 'tutorials/step', :locals => { :tutorial_id => @tutorial.id, :step => @step } %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment