similar to: post.author_id or post.author ? Rails bug?

Displaying 20 results from an estimated 60000 matches similar to: "post.author_id or post.author ? Rails bug?"

2006 Jan 09
1
Modifying script generated scaffold output Books/Authors
People, For my little book library db I find the rails script generated stuff fine for most of my needs but there is one thing I couldn''t figure out . . Part of the auto output of app/view/books/edit.rhtml is: <%= start_form_tag :action => ''update'', :id => @book %> <%= render :partial => ''form'' %> <%= submit_tag
2006 Mar 31
2
A.R. Associations problem
Hello, I''m learning A.R Associations by creating a simple forum that consists of 3 tables: ahuthors, topics and posts. This is the schema: class AddAuthorAndTopicAndPostTables < ActiveRecord::Migration def self.up create_table :authors do |t| t.column :username, :string t.column :email, :string t.column :created_on, :datetime end create_table
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
2009 May 24
6
belongs_to not saving foreign key
Under Rails 2.3.2 using a completely brand new project, I have 2 models: class Author < ActiveRecord::Base # name:string end class Book < ActiveRecord::Base # title:string belongs_to :author # author_id end And a simple test where i create a Book with an Author using the belongs_to and then update the foreign key directly: require ''test_helper'' class BookTest
2009 Aug 17
1
Problem with setter override on ActiveRecord
(This message was originally written on StackOverflow -- the formatting is much prettier there -- http://stackoverflow.com/questions/1283046/problem-with-setter-override-on-activerecord) This is not exactly a question, it''s rather a report on how I solved an issue with write_attribute when the attribute is an object, on Rails'' Active Record. I hope this can be useful to others
2007 May 31
0
Rails AR/SQLServer Unit Test: [6912] failed (but getting better)
"bitsweat" has given AR/SQLServer some love, but it''s still unhappy... http://dev.rubyonrails.org/changeset/6912 ------------------------------------------------------------------------ r6912 | bitsweat | 2007-05-31 10:15:56 -0700 (Thu, 31 May 2007) | 1 line Fix an edge case with find with a list of ids, limit, and offset. Closes #8437.
2006 Jun 13
6
Dead horse: validates_associated
Regarding validates_associated... Let''s say I have: article belongs_to author But for whatever reason, I want an article to also be written anonymously and therefore not require an author. Then I have: Article: belongs_to :author validates_associated :author But I DON''T have validates_presence_of. What I want to do is validate that an author is valid --if it is
2005 Dec 29
3
Verification problems
Hello, Hope this isn''t a newbie question - but I don''t seem to be able to find relevent information elsewhere. I am having trouble getting the following to work: Schema ====== ActiveRecord::Schema.define(:version => 1) do create_table "authors", :force => true do |t| t.column "name", :string end create_table "books", :force =>
2006 Sep 18
2
RedCloth !image! bug with filter_html
Hi all! I am trying tu set up RedCloth for user-submitted comments. And here is my problem. The :filter_html option just breaks images :-( For example, if I try in irb: string= "Some textile !agif.gif! and textile again" RedCloth.new(string, [:filter_html, :filter_styles]).to_html(:textile) I get: NoMethodError: You have a nil object when you didn''t expect it! The error
2010 Jun 29
3
belongs_to. Association methods don't pass data to DB
Hi. I have a problem with the association methods which passed to a model through a belongs_to declaration. Here''s an illustration of the issue: GIVEN: # migration class CreateArticlesAndAuthorsTables < ActiveRecord::Migration   def self.up     create_table :articles do |t|       t.text     :title       t.integer :author_id     end     create_table :authors do |t|       t.text
2006 Jan 22
11
ActiveRecord find
Suppose I have three tables - authors, posts and topics. Every post have a topic and every topic has an author, so I have posts.topic_id and topic.author_id. When the author is guest (not registered), author_id is nil. I need to find all the posts (in one query) where every post have all the information of the topic and the auther, so if p is one of those posts I could get the name of the
2009 Nov 11
4
Schema dump does not reflect column size limit
Hi, Everything is in the title. With Rails 2.3.4 and MySQL 5.0.41: If have a table like this: +----------------+------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL |
2006 Jul 20
2
a rails model question
Hi all, I am a newbie in ruby/rails. I have a question about my database model: table1: entities (name, description, author_id ...) table2: relations (source_id, target_id, relation_type) (it describes the relations between 2 entities and the relation type) How can I define models using rails, or do I need to redefine my database schema? thank you -- Posted via http://www.ruby-forum.com/.
2009 Dec 26
3
Does :class_name for belongs_to have to be a string and why?
Seemingly, when I use a symbol, I get an ActiveRecord error stating ''Can''t convert symbol into String.'' Why can''t I use a symbol here? Possibly this is a deeper misunderstanding of symbols in general on my part. #ActiveRecord error class Book < ActiveRecord::Base belongs_to :author, :class_name => :Person, :foreign_key => :author_id end #works
2011 May 20
3
How to handle non model data in form?
Hey, I got a form which looks like this: - form_for(@article, :html => {:multipart => true}, :url => articles_path) do |f| = errors_for(@article) .field = f.label :text %br = f.text_field :text .field = f.label :author_id %br = f.text_field :author_id .actions = f.submit But since I don''t want anyone to type in an author id I changed it
2006 Jan 05
1
recipes/categories to books/authors but listing doesn''t work
People, I have gone through the cookbook example: http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1 and everything worked fine an a FC4/Postgres setup. I then tried to reproduce this success with something that would be useful to me - a library db using books & authors tables. The author list works but NOT the book list (unless I take line #17 out). I get this message:
2006 Jan 22
2
suggest for "ambiguous column" when JOIN associated tables
Today I face with incorrect behavior in ActiveRecord. It take place when I try to use :include parameter for .find method. Where are two typical cases: 1. You have record with self-referential joins CREATE TABLE keywords (id, group_id); class Keyword < ActiveRecord::Base belongs_to :group, :class_name => "Keyword", :foreign_key =>
2006 May 07
3
Webrick not showing sql queries any more?
Hi all, I updated rails to 1.1.2, and somehow, when I run script/server on a new rails project, I don''t see the sql queries in the console any more... It was very useful to see them live... Does any one have any idea why? Thank you very much! Nauhaie -- Posted via http://www.ruby-forum.com/.
2006 Aug 09
0
Bug in ActiveRecord 1.14.4 and select_limited_ids_list method using mysql?!?!
All - I just upgraded to rails 1.1.5 (per the announcement) which also updated active record to 1.14.4 (was 1.14.2). I know have a problem... Author has many Articles... @authors = Author.find(:all, :limit => 10, :offset => 0 :include => [:articles], :conditions => ["hide =
2006 Aug 09
0
Bug in ActiveRecord 1.14.4 and select_limited_ids_list() ???
All - I just upgraded to rails 1.1.5 (per the announcement) which also updated active record to 1.14.4 (was 1.14.2). I know have a problem... Author has many Articles... @authors = Author.find(:all, :limit => 10, :offset => 0 :include => [:articles], :conditions => ["hide = ?",