Skip to content

Save not working on nested attributes #253

Description

@reejosamuel

Hi, Glad to see you are back and active again @remiprev

I have a model

class Branch

  include Her::Model

  belongs_to :Shop

  attributes  :email,         :address_line1,
             :address_line2, :landmark,      :pin,
             :phone,         :settlement_time
.... more stuff ..
end

and Shop.rb

class Shop
  include Her::Model

  has_many :branches

... more stuff....
end

and in the controller for Branches I'm doing a update action

 def update
    @shop = Shop.find(params[:merchant_id])
    @shop.branches.assign_attributes(branch_params)

    respond_to do |format|
      if @shop.branches.save
        format.html { redirect_to @branch, notice: 'Branch was successfully updated.' }
      else
        format.html { render :edit }
      end
    end
  end

This leads to undefined method "assign_attributes" for #<Her::Collection:0x00000106fc2860>

also If i try to do save on @branch then i calls PUT the url www.example.com/ branch/1 instead of www.example.com/ shop/1/branch/1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions