Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## my model: client.rb
- class Client < ActiveRecord::Base
- validates_presence_of :name
- has_many :projects
- has_many :work_orders
- has_one :user
- accepts_nested_attributes_for :work_orders, :allow_destroy => true
- accepts_nested_attributes_for :user
- end
- ## from my controller: pages_controller.rb
- def order
- @client = Client.new # _with_user_and_work_orders
- @client.work_orders.build
- # @client.user.build #kills my view every time! ("NoMethodError in PagesController#order")
- end
- ## my view: order.haml
- =error_messages_for :client
- -form_for @client do |order_form|
- #client
- %h2 Your Name or Company Name:
- =order_form.text_field :name, :class => "form", :size => "30"
- %hr
- #user_creation
- -order_form.fields_for @user do |user_form| #If I use ":user" my view dies, claiming "The error occurred while evaluating nil.new_record?"
- =user_form.text_field :username
- =user_form.text_field :firstname
- =user_form.text_field :lastname
- =user_form.password_field :password
- =user_form.password_field :password_confirmation
- #work_orders
- -order_form.fields_for :work_orders do |wo_form|
- %h2 Project Variety:
- =wo_form.select("variety", [["Article", 'article'], ["Blog Post/Entry", 'blog'], ["Press Release", 'press release' ], ["Other Website Content", 'other']], :class => "form")
- %h2 Project Title/Description:
- =wo_form.text_field :name, :class => "form", :size => "30"
- =wo_form.text_area :client_description, :class => "form", :size => "51x4"
- %hr.thin
- =order_form.submit "Submit"
Add Comment
Please, Sign In to add comment