search for: bookstat

Displaying 1 result from an estimated 1 matches for "bookstat".

Did you mean: hookstat
2011 Jun 27
2
insert value of primary key into another field before record is saved
Hey all, I created a seed task: def books! books = Book.where(:type_id => Type.find_by_name(''Fiction'')).order(''id'') books.each do |book| @books = 4.times.map do |i| subbook! "#{book.book_num}-#{i}".to_s, :book_state => BookState[:available].id, :book => book end end puts "log it: #{@books.is_a?(Array)}" #array of book objects courtesy of map end def subbook!(book_num, options = {}) defaults = { :book_num => book_num } Subbook.create!(defaults.merge(options)) end My p...