search for: book_ids

Displaying 20 results from an estimated 25 matches for "book_ids".

Did you mean: book_id
2006 Dec 20
7
has_many :through does it support collection_singular_ids ?
Good evening list members, I have the following model: class Author < ActiveRecord::Base has_many :authorships has_many :books, :through => : authorships end Should I be able to do the following? Author.find(:first).book_ids = [1,2,3] I ask, because it doesn''t. The docs state that it should, but it doesn''t specialise in the case of a :through This works fine BTW: Author.find(:first).authorship_ids = [12,13] Do I really need to find and add (<<) my associated join models for books one b...
2006 Mar 04
10
Help setting up relationships needed
This is a bit of a long question, but to those of you with some experience, it should be fairly simple I think. I have a notes page that should list all notes the user has entered for all books chronologically like this. Book One: This is the note. Book Four: This is the note. Book One: A different note, entered later. Right now my models are: User has_many :books Book has_many
2006 Mar 19
3
Table belongs_to either of two other tables?
Suppose I have a site about books and authors, and users can leave comments on either a book or an author. I''d want to have a table called "comments", which could belong to either an author OR a book. In my structure I wouldn''t be sure whether to include an "author_id" or a "book_id", or both. What would be the best way to handle this
2010 Aug 28
1
validates_uniqueness_of missing in rails 3.0 rc2?
Has anybody noticed validates_uniqueness_of missing in rails 3.0 rc2? I''m not sure if this is a bug or I''m just doing something wrong. Here''s what I''m doing. Class 1: class Title < ActiveRecord::Base validates_length_of :language, :is => 3 validates_uniqueness_of :language, :scope => :book_id validate :language,
2006 Mar 18
1
Need help .. Rails Recipes, in_place_editor, selecting associations
Hi, I am currently reading the Rails Recipes book and like the chapter on providing your own in_place_editor for enumerations / selects. I understood so far, or I believe that I understood ;-), how to do that for a field that uses values only, like choosing from "red", "black", "green". What I fail to understand is how to chose from associated objects?!
2014 Apr 16
0
Configure restful web service in rails
Hi, I am trying to create a Rest web service in my rails application. I need to configure urls for it as below. localhost:3000/book/book_id/new/param1/param2/param3/param4/... localhost:3000/book/book_id/next localhost:3000/book/book_id/delete I dont have a view pages for it since it returns in json format.Please help.So what is the best way to configure these urls via
2006 Jun 13
0
question about saving associations when using has_many :through
I''ve got a User model and a Book model. A user is required to submit books each month to be reviewed by other users. I have the following relationships defined: # the join model book_review.rb belongs_to :user belongs_to :book end book.rb # each book is reviewed by many users. This allows us to get the BookReview # objects associated with this book has_many :book_reviews,
2006 Aug 11
2
User Favorites
Hi there, I''m currently creating a simple (at least so I thought) structure of user favorites. Basically users can add certain ''objects'' to their list of favorites. Here is my current structure (simplified) class User has_many :favorites end class Book belongs_to :favorites end class Favorite belongs_to :user has_one :book end The table favorite just has a two
2006 Jan 18
2
categories/recipes & books/descriptions - has_many vs has_one => id question
People, In the cookbook eg, categories has_many recipes but in a book eg, book has_one description - doesn''t that mean that the id of the description should be the same as the id of the book (instead of having it''s own "description_id" in the book table? Thanks, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney
2005 May 25
2
URLS and Human Factors
This post addresses URLs generated by Ruby on Rails from a human factors point of view. Allow me to use Hieraki as an example. Hieraki is a great application. It was one of my first introductions to the power of Ruby on Rails. Scenario: When I navigated to Chapter 1 of a book the URL in my address bar was http://www.library.com/read/chapter/6. This inconsistancy ("Am I on Chapter 1 or
2007 Aug 23
3
AAF: find_by_contents on AR Association Total Hits
I seem to be getting some behaviour thats unexpected (for me anyway) when using find_by_contents on an ActiveRecord has_many association. The results that are returned are only the records that belong to the model returned, but the total_hits that are being returned appear to be for the whole table. e.g. class Book < AR::Base has_many :pages end class Page < AR::Base belongs_to :book
2006 Jun 07
10
habtm "AND" find conditions
I have two tables and a join table for them e.g. books, authors in a many to many relationship (habtm) and a join table books_authors. I can successfully search for a book that has "author.id = 2 OR author.id = 4" but I am unable to search for "author.id = 2 AND author.id = 4" This is because the result of all the joins only has one author.id column so no single row has
2010 Sep 21
25
Working in install acts_as_commentable, On create, error: "unknown attribute: book_id"
Hello, I''m working to install the acts_as_commentable plugin on my Rails 3 app. After adding "acts_as_commentable" to my book model, I then added a comment form on my book show view: <% form_for(@comment) do|f| %> <%= f.hidden_field :book_id %> <%= f.label :comment %><br /> <%= f.text_area :comment %> <%= f.submit "Post
2007 Aug 15
3
ActsAsList specs
Hi, How are people specifying models which act_as_list? I''m thinking that it would be possible to check that acts_as_list instance methods have been added to a class using something like this: describe Page, "acts_as_list" do it "should act as a list" do Page.ancestors.should be_include(ActiveRecord::Acts::List::InstanceMethods) end it "should use
2007 Jul 24
11
Mock or Stub strategy for validates_uniqueness_of
Hi, I''m a bit stuck with mocking a unit test of a join model with regards to a validates_uniqueness_of clause. I have class Book < AR:B has_many :clippings various validates_presence_of etc end class Clip < AR:B has_many :clippings various validates_presence_of etc end class Clipping < AR:B belongs_to :book belongs_to :clip validates_uniqueness_of :clip_id,
2011 Feb 07
2
Search HABTM relationship in ActiveRecord
Consider the following scenario: Book has_and_belong_to_many Category. In other words, a category may have a lot of books, and a book can have more than one category. What is the best practice to query all books related to some specified categories. For example, if I have following books "From Java To Ruby" - Category: Java, Ruby "Ruby Programming" - Category: Ruby
2005 Mar 08
19
find_by_sql ON STEROID possible?
find_by_sql BREAKS THE OOP BEAUTY and perhaps we can solve that. NAMING CONVENTIONS can perhaps make find_by_sql much more clever. lets imagine that relation: publishers <- books <-> authors_books <-> authors -> universities (can''t find something else than university for that last association :) ) imagine we want to fetch every book and every associated
2006 May 10
7
has_many :through scope on join attribute
Hi I have a has_many :through. It''s a basic mapping of Project id .... User id .... TeamMembers project_id user_id role What I would like to do is have different roles so I can have in the project model has_many :core_members, :through => :team_members, :source => :user but I would like to limit this to only those with the "core" role in the team members table for
2006 Jul 06
0
Paging with multiple tables/models
I''m looking for a smooth way to implement paging over a combination of two tables. My application tracks which books and movies you have borrowed from me. For reasons that make sense elsewhere in the application, these are seperated out into two tables: book_borrowers and movie_borrowers and therefore 2 different activerec objects: BookBorrower and MovieBorrower This particular screen
2006 Apr 05
0
Has Many :through associations
Greetings again: I''m simplifying the case I presented earlier regarding the use of has_many :through. I''m using DHH''s example from "Persuing Beauty with Ruby On Rails". Here are his models: class Author < ActiveRecord::Base has_many :authorships has_many :books, :through => :authorships end class Book < ActiveRecord::Base has_many