ruby on rails - error when updating whilst using acts-as-taggable -


good morning everyone,

i've been stumped error days or 2 now.

my app small "sample request log" textiles based company, needs track samples , able edit/submit/delete them. whenever try update or create new request "undefined method `each' "x":string" x option chosen in drop down list (the drop down list populated controller.)

request_controller.rb:

class requestscontroller < applicationcontroller before_action :set_request, only: [:show, :edit, :update, :destroy]    # /requests   # /requests.json   def index     if params[:tag]      @requests = request.tagged_with(params[:tag])     else      @requests = request.all      @requests = request.order("request_date asc")     end   end   # /requests/1  # /requests/1.json  def show  end   # /requests/new  def  new   @request = request.new   @customers = customer.all   @suppliers = supplier.all   @designers = designer.all   @statuses = status.all  end  # /requests/1/edit  def edit   @customers = customer.all   @suppliers = supplier.all   @designers = designer.all   @statuses = status.all  end  # post /requests # post /requests.json  def create   @request = request.new(request_params)   @customers = customer.all   @suppliers = supplier.all   @designers = designer.all   @statuses = status.all     respond_to |format|     if @request.save       format.html { redirect_to @request, notice: 'request created.' }       format.json { render action: 'show', status: :created, location: @request }     else       format.html { render action: 'new' }       format.json { render json: @request.errors, status: :unprocessable_entity }     end   end end  # patch/put /requests/1 # patch/put /requests/1.json  def update   @customers = customer.all  @suppliers = supplier.all  @designers = designer.all  @statuses = status.all  respond_to |format|   if @request.update(request_params)     format.html { redirect_to @request, notice: 'request updated.' }     format.json { head :no_content }   else     format.html { render action: 'edit' }     format.json { render json: @request.errors, status: :unprocessable_entity }   end   end end  # delete /requests/1 # delete /requests/1.json  def destroy   @request.destroy  respond_to |format|   format.html { redirect_to requests_url }   format.json { head :no_content }  end end  def tagged   if params[:tags].present?      @requests = request.tagged_with(params[:tags])   else      @requests = request.postall   end   end  private   # use callbacks share common setup or constraints between actions.   def set_request     @request = request.find(params[:id])   end  # never trust parameters scary internet, allow white list through. def request_params   params.require(:request).permit(:request_date, :request_smd_number, :request_brief_description, :request_description, :request_supplier, :request_colours, :request_date_required, :request_required_for, :request_designer, :request_comments, :request_confirmed_comp_date, :request_received, :request_received_date, :request_date_sent, :request_tracking_number, :request_confirmed_comp_date, :request_confirmed_comp_date2, :request_confirmed_comp_date3, :request_confirmed_comp_date4, :request_confirmed_comp_date5, :request_confirmed_comp_date6, :tag_list, :tags, :supplier, :customer, :designer, :name) end  end 

requests.rb

class request < activerecord::base  validates_presence_of :request_smd_number, :request_date, :request_date_required,  :request_required_for, :request_brief_description, :request_comments, :tags, :request_supplier   belongs_to :customer belongs_to :designer belongs_to :supplier belongs_to :status has_many :tags  accepts_nested_attributes_for :customer accepts_nested_attributes_for :designer accepts_nested_attributes_for :supplier accepts_nested_attributes_for :status  acts_as_taggable_on :requests, :tags, :tag_list  end 

the form i'm using can found @ https://github.com/jackybigz/samplelog/blob/master/app/views/requests/_form.html.erb (linking git instead of pasting in keep thread small.)

whenever take out last line of form '

<td class="span3"><%= collection_select :request, :tags, @statuses, :name, :name %></td>' 

it works fine , updates request i've narrowed down that, after shifting bunch of relations , other things around, trying updates , different gem versions i've come against rock , hard place.

i'm reasonably new ruby , rails , suggestions helpful, thanks.

p.s i've gone different way apps code should of kind of works it's how did it.

edit here trace error.

activerecord (4.0.0) lib/active_record/associations/collection_association.rb:333:in `replace' activerecord (4.0.0) lib/active_record/associations/collection_association.rb:42:in `writer' activerecord (4.0.0) lib/active_record/associations/builder/association.rb:78:in `tags=' activerecord (4.0.0) lib/active_record/attribute_assignment.rb:42:in `public_send' activerecord (4.0.0) lib/active_record/attribute_assignment.rb:42:in `_assign_attribute' activerecord (4.0.0) lib/active_record/attribute_assignment.rb:29:in `block in assign_attributes' activerecord (4.0.0) lib/active_record/attribute_assignment.rb:23:in `each' activerecord (4.0.0) lib/active_record/attribute_assignment.rb:23:in `assign_attributes' activerecord (4.0.0) lib/active_record/persistence.rb:229:in `block in update' activerecord (4.0.0) lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction' activerecord (4.0.0) lib/active_record/transactions.rb:209:in `transaction' activerecord (4.0.0) lib/active_record/transactions.rb:323:in `with_transaction_returning_status' activerecord (4.0.0) lib/active_record/persistence.rb:228:in `update' app/controllers/requests_controller.rb:67:in `block in update' actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:363:in `call' actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:363:in `retrieve_collector_from_mimes' actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:189:in `respond_to' app/controllers/requests_controller.rb:66:in `update' actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.0.0) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action' activesupport (4.0.0) lib/active_support/callbacks.rb:413:in `_run__1386668850689043198__process_action__callbacks' activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks' actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action' activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process' actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process' actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch' actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call' rack (1.5.2) lib/rack/etag.rb:23:in `call' rack (1.5.2) lib/rack/conditionalget.rb:35:in `call' rack (1.5.2) lib/rack/head.rb:11:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241: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.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call' activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call' activerecord (4.0.0) lib/active_record/migration.rb:369:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__1572239184247043471__call__callbacks' activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app' railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged' railties (4.0.0) lib/rails/rack/logger.rb:21:in `call' actionpack (4.0.0) 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.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call' railties (4.0.0) lib/rails/engine.rb:511:in `call' railties (4.0.0) lib/rails/application.rb:97:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process' thin (1.5.1) lib/thin/connection.rb:79:in `catch' thin (1.5.1) lib/thin/connection.rb:79:in `pre_process' thin (1.5.1) lib/thin/connection.rb:54:in `process' thin (1.5.1) lib/thin/connection.rb:39:in `receive_data' eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine' eventmachine (1.0.3) lib/eventmachine.rb:187:in `run' thin (1.5.1) lib/thin/backends/base.rb:63:in `start' thin (1.5.1) lib/thin/server.rb:159:in `start' rack (1.5.2) lib/rack/handler/thin.rb:16:in `run' rack (1.5.2) lib/rack/server.rb:264:in `start' railties (4.0.0) lib/rails/commands/server.rb:84:in `start' railties (4.0.0) lib/rails/commands.rb:78:in `block in <top (required)>' railties (4.0.0) lib/rails/commands.rb:73:in `tap' railties (4.0.0) lib/rails/commands.rb:73:in `<top (required)>' bin/rails:4:in `require' bin/rails:4:in `<main>' 

i found answer morning, came @ fresh head , kind of got it.

<td class="span3"><%= collection_select :request, :tags, @statuses, :name, :name %></td> 

replaced :tags :tag_list in collection select , works now.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -