Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index.html.erb # problems
- ========
- <%= link_to "New problem", new_problem_solution_path(@problem), id: "new-solution-link", remote: true %>
- solutions_controller
- ========
- class SolutionsController < ApplicationController
- def new
- @step = Solution.new
- @step.problem_id = params[:problem_id]
- respond_to do |format|
- format.js
- format.html { redirect_to root_path }
- end
- end
- end
- new.js.erb
- =========
- $('#new-solution-link').hide().after('<%= j render("form") %>')
- _form.html.erb
- ========
- <%= form_for @step, remote: true do |f| %>
- <%= f.text_field :title %>
- <%= f.submit 'Ok'%>
- <% end %>
- routes.rb
- ========
- resources :problems do
- resources :solutions
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement