0

Here is my newbie story,

my table looks like this:

  create_table "books", :force => true do |t|
    t.string   "title"
    t.integer  "count"
    t.integer  "id"
  end

  create_table "users", :force => true do |t|
    t.string   "name"
    t.decimal   "money"
  end

user can create many books, and user using these forms to update it:

to update money:

<%= form_for(@user) do |f| %>
    <%= f.number_field :money, :value => @user.money %>
<% end %>

to update book title, count etc., for each books:

<% @book.each do |book| %>
    <%= form_for(book) do |f| %>
        <%= f.number_field :count %>
        <%= f.text_field :title %>
    <% end %>
<% end %>

and im trying to do is i want update both of them. (lets say user need to update money and book title) currently it only able to update money or book info separately

model:

class Book < ActiveRecord::Base
  attr_accessible :count, :title, :id
  belongs_to :user
end

any idea? Thanks!

1 Answer 1

1

It's not that simple to explain in a single answer. I suggest you to have a look at the following Railscasts to get an idea.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.