I have this model
class User
include Mongoid::Document
authenticates_with_sorcery!
has_one :user_details
field :email , type: String
field :id_number , type: String
field :crypted_password , type: String
field :salt , type: String
field :fname , type: String
field :lname , type: String
field :mname , type: String
end
And I want to add a relation to this model
class UserDetails
include Mongoid::Document
belongs_to :user
#fields
field :year , type: String
field :block , type: String
field :course , type: String
field :alumni , type: Boolean
end
but when I used it in my form it says Undefined Method 'year' I tried to belongs_to :users, has_many :user_detail already still the same this is in the view
=f.text_field :year , placeholder: "Year"
Log Error
Started GET "/admin/users/new" for 127.0.0.1 at 2014-12-16 20:15:32 +0800
Processing by Admin::UsersController#new as HTML Rendered admin/app/views/admin/users/_form.html.haml (4.8ms) Rendered admin/app/views/admin/users/new.html.haml within layouts/admin/application (6.7ms) Completed 500 Internal Server Error in 11ms
ActionView::Template::Error (undefined method term' for #<User:0xa9f0a24>):
66: %section.col.col-3
67: %label.input
68: %i.icon-prepend.fa.fa-user
69: =f.text_field :term , placeholder: "Year"
70: %b.tooltip.tooltip-top-left
71: %i.fa.fa-warning.text-warning-teal Year
72: %section.col.col-3
actionview (4.1.7) lib/action_view/helpers/tags/base.rb:28:in
value'
actionview (4.1.7) lib/action_view/helpers/tags/base.rb:37:in value_before_type_cast'
actionview (4.1.7) lib/action_view/helpers/tags/text_field.rb:9:in
block in render'
actionview (4.1.7) lib/action_view/helpers/tags/text_field.rb:9:in fetch'
actionview (4.1.7) lib/action_view/helpers/tags/text_field.rb:9:in
render'
actionview (4.1.7) lib/action_view/helpers/form_helper.rb:771:in text_field'
actionview (4.1.7) lib/action_view/helpers/form_helper.rb:1258:in
text_field'
admin/app/views/admin/users/_form.html.haml:69:in block in _admin_app_views_admin_users__form_html_haml___623088800__625367368'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:132:in
call'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:132:in block (2 levels) in form_for_with_haml'
haml (4.1.0.beta.1) lib/haml/helpers.rb:284:in
with_tabs'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:132:in block in form_for_with_haml'
actionview (4.1.7) lib/action_view/helpers/capture_helper.rb:38:in
block in capture'
actionview (4.1.7) lib/action_view/helpers/capture_helper.rb:200:in with_output_buffer'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_xss_mods.rb:5:in
with_output_buffer_with_haml_xss'
actionview (4.1.7) lib/action_view/helpers/capture_helper.rb:38:in capture'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:47:in
capture_with_haml'
actionview (4.1.7) lib/action_view/helpers/form_helper.rb:434:in form_for'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:134:in
form_for_with_haml'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_xss_mods.rb:28:in form_for_with_haml_xss'
admin/app/views/admin/users/_form.html.haml:1:in
_admin_app_views_admin_users__form_html_haml___623088800__625367368'
actionview (4.1.7) lib/action_view/template.rb:145:in block in render'
activesupport (4.1.7) lib/active_support/notifications.rb:161:in
instrument'
actionview (4.1.7) lib/action_view/template.rb:339:in instrument'
actionview (4.1.7) lib/action_view/template.rb:143:in
render'
actionview (4.1.7) lib/action_view/renderer/partial_renderer.rb:306:in render_partial'
actionview (4.1.7) lib/action_view/renderer/partial_renderer.rb:279:in
block in render'
actionview (4.1.7) lib/action_view/renderer/abstract_renderer.rb:38:in block in instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in
block in instrument'
activesupport (4.1.7) lib/active_support/notifications/instrumenter.rb:20:in instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in
instrument'
actionview (4.1.7) lib/action_view/renderer/abstract_renderer.rb:38:in instrument'
actionview (4.1.7) lib/action_view/renderer/partial_renderer.rb:278:in
render'
actionview (4.1.7) lib/action_view/renderer/renderer.rb:47:in render_partial'
actionview (4.1.7) lib/action_view/renderer/renderer.rb:21:in
render'
actionview (4.1.7) lib/action_view/helpers/rendering_helper.rb:32:in render'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:10:in
block in render_with_haml'
haml (4.1.0.beta.1) lib/haml/helpers.rb:89:in non_haml'
haml (4.1.0.beta.1) lib/haml/helpers/action_view_mods.rb:10:in
render_with_haml'
admin/app/views/admin/users/new.html.haml:1:in _admin_app_views_admin_users_new_html_haml___282327175__623578238'
actionview (4.1.7) lib/action_view/template.rb:145:in
block in render'
activesupport (4.1.7) lib/active_support/notifications.rb:161:in instrument'
actionview (4.1.7) lib/action_view/template.rb:339:in
instrument'
actionview (4.1.7) lib/action_view/template.rb:143:in render'
actionview (4.1.7) lib/action_view/renderer/template_renderer.rb:55:in
block (2 levels) in render_template'
actionview (4.1.7) lib/action_view/renderer/abstract_renderer.rb:38:in block in instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in
block in instrument'
activesupport (4.1.7) lib/active_support/notifications/instrumenter.rb:20:in instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in
instrument'
actionview (4.1.7) lib/action_view/renderer/abstract_renderer.rb:38:in instrument'
actionview (4.1.7) lib/action_view/renderer/template_renderer.rb:54:in
block in render_template'
actionview (4.1.7) lib/action_view/renderer/template_renderer.rb:62:in render_with_layout'
actionview (4.1.7) lib/action_view/renderer/template_renderer.rb:53:in
render_template'
actionview (4.1.7) lib/action_view/renderer/template_renderer.rb:17:in render'
actionview (4.1.7) lib/action_view/renderer/renderer.rb:42:in
render_template'
actionview (4.1.7) lib/action_view/renderer/renderer.rb:23:in render'
actionview (4.1.7) lib/action_view/rendering.rb:99:in
_render_template'
actionpack (4.1.7) lib/action_controller/metal/streaming.rb:217:in _render_template'
actionview (4.1.7) lib/action_view/rendering.rb:82:in
render_to_body'
actionpack (4.1.7) lib/action_controller/metal/rendering.rb:32:in render_to_body'
actionpack (4.1.7) lib/action_controller/metal/renderers.rb:32:in
render_to_body'
actionpack (4.1.7) lib/abstract_controller/rendering.rb:25:in render'
actionpack (4.1.7) lib/action_controller/metal/rendering.rb:16:in
render'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:41:in block (2 levels) in render'
activesupport (4.1.7) lib/active_support/core_ext/benchmark.rb:12:in
block in ms'
/home/laziendo/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:294:in realtime'
activesupport (4.1.7) lib/active_support/core_ext/benchmark.rb:12:in
ms'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:41:in block in render'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:84:in
cleanup_view_runtime'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:40:in render'
actionpack (4.1.7) lib/action_controller/metal/implicit_render.rb:10:in
default_render'
actionpack (4.1.7) lib/action_controller/metal/implicit_render.rb:5:in send_action'
actionpack (4.1.7) lib/abstract_controller/base.rb:189:in
process_action'
actionpack (4.1.7) lib/action_controller/metal/rendering.rb:10:in process_action'
actionpack (4.1.7) lib/abstract_controller/callbacks.rb:20:in
block in process_action'
activesupport (4.1.7) lib/active_support/callbacks.rb:82:in run_callbacks'
actionpack (4.1.7) lib/abstract_controller/callbacks.rb:19:in
process_action'
actionpack (4.1.7) lib/action_controller/metal/rescue.rb:29:in process_action'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:31:in
block in process_action'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in block in instrument'
activesupport (4.1.7) lib/active_support/notifications/instrumenter.rb:20:in
instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in instrument'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:30:in
process_action'
actionpack (4.1.7) lib/action_controller/metal/params_wrapper.rb:250:in process_action'
actionpack (4.1.7) lib/abstract_controller/base.rb:136:in
process'
actionview (4.1.7) lib/action_view/rendering.rb:30:in process'
actionpack (4.1.7) lib/action_controller/metal.rb:196:in
dispatch'
actionpack (4.1.7) lib/action_controller/metal/rack_delegation.rb:13:in dispatch'
actionpack (4.1.7) lib/action_controller/metal.rb:232:in
block in action'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:82:in call'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:82:in
dispatch'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:50:in call'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:73:in
block in call'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:59:in each'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:59:in
call'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:678:in call'
railties (4.1.7) lib/rails/engine.rb:514:in
call'
railties (4.1.7) lib/rails/railtie.rb:194:in public_send'
railties (4.1.7) lib/rails/railtie.rb:194:in
method_missing'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:73:in block in call'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:59:in
each'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:59:in call'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:678:in
call'
rack (1.5.2) lib/rack/etag.rb:23:in call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in
call'
rack (1.5.2) lib/rack/head.rb:11:in call'
actionpack (4.1.7) lib/action_dispatch/middleware/params_parser.rb:27:in
call'
actionpack (4.1.7) lib/action_dispatch/middleware/flash.rb:254:in call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in
context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call'
actionpack (4.1.7) lib/action_dispatch/middleware/cookies.rb:560:in
call'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:29:in block in call'
activesupport (4.1.7) lib/active_support/callbacks.rb:82:in
run_callbacks'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in call'
actionpack (4.1.7) lib/action_dispatch/middleware/reloader.rb:73:in
call'
actionpack (4.1.7) lib/action_dispatch/middleware/remote_ip.rb:76:in call'
actionpack (4.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:17:in
call'
actionpack (4.1.7) lib/action_dispatch/middleware/show_exceptions.rb:30:in call'
railties (4.1.7) lib/rails/rack/logger.rb:38:in
call_app'
railties (4.1.7) lib/rails/rack/logger.rb:20:in block in call'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in
block in tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in
tagged'
railties (4.1.7) lib/rails/rack/logger.rb:20:in call'
actionpack (4.1.7) lib/action_dispatch/middleware/request_id.rb:21:in
call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call'
rack (1.5.2) lib/rack/runtime.rb:17:in
call'
activesupport (4.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in call'
rack (1.5.2) lib/rack/lock.rb:17:in
call'
actionpack (4.1.7) lib/action_dispatch/middleware/static.rb:84:in call'
rack (1.5.2) lib/rack/sendfile.rb:112:in
call'
railties (4.1.7) lib/rails/engine.rb:514:in call'
railties (4.1.7) lib/rails/application.rb:144:in
call'
rack (1.5.2) lib/rack/lock.rb:17:in call'
rack (1.5.2) lib/rack/content_length.rb:14:in
call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in service'
/home/laziendo/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in
service'
/home/laziendo/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run'
/home/laziendo/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in
block in start_thread'
Rendered /home/laziendo/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.8ms) Rendered /home/laziendo/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.7ms) Rendered /home/laziendo/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (17.8ms)
User.new
but there's no such year,block,course,alumni fields – nsantiago2719field :term , type: String
– nsantiago2719