ruby on rails - Mongoid Relation -
i have 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 want add relation 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 used in form says undefined method 'year' tried belongs_to :users, has_many :user_detail still same in view
=f.text_field :year , placeholder: "year"
log error
started "/admin/users/new" 127.0.0.1 @ 2014-12-16 20:15:32 +0800
processing admin::userscontroller#new 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' #<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)
the error saying user doesn't have method named 'year', doesn't. userdetails does. need access year userdetails.
Comments
Post a Comment