Guest User

Untitled

a guest
May 29th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. MODELS
  2. ======
  3.  
  4. class Todo < ActiveRecord::Base
  5. belongs_to :user
  6.  
  7. validates :title, :presence => true, :length => { :maximum => 65 }
  8.  
  9. scope :recent, order("created_at DESC")
  10. scope :incomplete, recent.where(["done = ?", false])
  11. end
  12.  
  13. class User < ActiveRecord::Base
  14.  
  15. # Include default devise modules. Others available are:
  16. # :token_authenticatable, :confirmable, :lockable and :timeoutable
  17. devise :database_authenticatable, :registerable,
  18. :recoverable, :rememberable, :trackable, :validatable
  19.  
  20. # Setup accessible (or protected) attributes for your model
  21. attr_accessible :email, :password, :password_confirmation
  22.  
  23. has_many :todos
  24. end
  25.  
  26. ROUTES
  27. ======
  28. Karya::Application.routes.draw do |map|
  29. resources :users do
  30. resources :todos do
  31. post :mark_done, :on => :collection
  32. end
  33. end
  34.  
  35. devise_for :users
  36.  
  37. root :to => "todos#index"
  38. end
  39.  
  40. PROBLEM WITH form_form (Added new lines to read better)
  41. =======================================================
  42. (ruby-1.9.2@dev)(~/projects/karya)९ rails c -s
  43. Loading development environment in sandbox (Rails 3.0.0.beta4)
  44. Any modifications you make will be rolled back on exit
  45.  
  46. ruby-1.9.2-head > user = User.find(1)
  47. => #<User id: 1, email: "hello@rohitarondekar.com", encrypted_password: "$2a$10$03wAcpK/y10kGB8pURWHZev4wDexsK2/4Ox8e/elcJjf...", password_salt: "$2a$10$03wAcpK/y10kGB8pURWHZe", reset_password_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2010-06-24 04:32:58", updated_at: "2010-06-24 04:32:58">
  48.  
  49.  
  50. ruby-1.9.2-head > new_todo = user.todos.new
  51. => #<Todo id: nil, title: nil, created_at: nil, updated_at: nil, done: false, user_id: 1>
  52.  
  53.  
  54. ruby-1.9.2-head > helper.form_for(new_todo) { |f| f.submit "submit" }
  55. NoMethodError: undefined method `polymorphic_path' for #<ActionView::Base:0x0000000313aaf8>
  56. from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/actionpack-3.0.0.beta4/lib/action_view/helpers/form_helper.rb:329:in `apply_form_for_options!'
  57. from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/actionpack-3.0.0.beta4/lib/action_view/helpers/form_helper.rb:301:in `form_for'
  58. from (irb):3
  59. from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/railties-3.0.0.beta4/lib/rails/commands/console.rb:47:in `start'
  60. from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/railties-3.0.0.beta4/lib/rails/commands/console.rb:8:in `start'
  61. from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/railties-3.0.0.beta4/lib/rails/commands.rb:23:in `<top (required)>'
  62. from script/rails:9:in `require'
  63. from script/rails:9:in `<main>'
Add Comment
Please, Sign In to add comment