daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Mar 2nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. index.html.erb # problems
  2. ========
  3. <%= link_to "New problem", new_problem_solution_path(@problem), id: "new-solution-link", remote: true %>
  4.  
  5.  
  6. solutions_controller
  7. ========
  8. class SolutionsController < ApplicationController
  9.   def new
  10.     @step = Solution.new
  11.     @step.problem_id = params[:problem_id]
  12.  
  13.     respond_to do |format|
  14.       format.js
  15.       format.html { redirect_to root_path }
  16.     end
  17.   end
  18. end
  19.  
  20. new.js.erb
  21. =========
  22. $('#new-solution-link').hide().after('<%= j render("form") %>')
  23.  
  24. _form.html.erb
  25. ========
  26. <%= form_for @step, remote: true do |f| %>
  27.     <%= f.text_field :title %>
  28.     <%= f.submit 'Ok'%>
  29. <% end %>
  30.  
  31.  
  32. routes.rb
  33. ========
  34. resources :problems do
  35.     resources :solutions
  36. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top