similar to: How to handle non model data in form?

Displaying 20 results from an estimated 1000 matches similar to: "How to handle non model data in form?"

2005 Apr 20
4
Error in tutorial or sintax changed?
Hi, In this tutorial http://wiki.rubyonrails.com/rails/show/HowtoUseJoinsWithFindAll it sad: sql =<<SQL SELECT articles.*, authors.name AS author_name FROM articles LEFT JOIN authors ON author_id = authors.id SQL and this return *app/controllers/media_controller.rb:366: can''t find string "SQL" anywhere before EOF* what is wrong? the tutorial or ruby changed? please,
2008 Jan 15
7
PHP indexing, what's the PHP method for indexscript
Currently I have the following indexscript: pid : unique=Q boolean=Q field=pid postdate : field=startdate author_name: unhtml boolean=XAUTHORNAME field=author author_id: boolean=XAUTHORID field=authorid url : field=url sample : weight=1 index field=sample How can I create the same indexing using PHP? With this, I can get an searchable index, but I have no idea how to set the fields, so that I
2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
(I posted this as a bug in GitHub (https://github.com/rails/rails/issues/7018), but then someone there told me I should post it here, so here it is.) If you set attr_accessible on some properties in an ActiveRecord-descended class, and then attr_protected on others - the class becomes ''default-open'' - if any properties are missed or added later, they will be accessible by
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
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
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
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 =>
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
2007 Jan 24
2
attr_accessor vs attr_accessible
Please guide me how to use those two methods. I can''t differentiate them. I was doing something on my model and I have put one field in the attr_accessible method. After that when I try to run the app the app always says my other fields are blank, but they''re all filled up. What''s wrong with it? Thanks --~--~---------~--~----~------------~-------~--~----~ You received
2008 Jan 10
2
Getting results matching with an array?
I have an array authors=[1,3,7] and I want to get all the posts that match with any or all of these results. something like... posts = Post.find(:all, [:conditions => ''''author_id = ?'', authors]) of course this wont work but I need something like it that works.. thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~
2005 Oct 14
1
Diff between attr_accessible and attr_accessor
I''m going though the paper back edition of agile development with Rails. On page #128 I encountered following lines of code: attr_accessor :password attr_accessible :name,:password What''s the difference between attr_accessor and attr_accessible? -=- Neeraj _______________________________________________ Rails mailing list
2011 Mar 07
3
difference between attr_accessor and attr_accessible?
Hi, What''s the difference between attr_accessor and attr_accessible? Is attr_accessor to create a virtual variable/object and attr_accessible makes it accessible? Do you need attr_accessible if you already have attr_accessor? Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
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
2006 Jun 11
3
[SUMMARY] Rails Core Weekly June 5 - June 11
Dear list, This weeks RCW has a slightly different format than before. After all, since what we want is less bloat, this RCW is less verbose. Please do let me know what you think off-list. *Interesting stuff on the Rails Timeline* _Fixed and commited to trunk:_ An issue with not null columns in SQLite3 migrations(<a
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 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 =>
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
2006 Apr 09
6
Write/Display AR query as Grouped Results?
I''ve got a publications table that contains an author_id foreign key and a pubrole_id foreign key. What I want to do is query the DB using AR so that I can get a list of all publications that belong_to a particular author, and group the results by the pubrole.role_name (Author, Joint Author, Editor, etc.) so that the results look something like: Author book1 info book2 info etc.
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
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