Displaying 20 results from an estimated 200 matches similar to: "Schema dump does not reflect column size limit"
2011 Jun 15
1
.new_record? and :_destroy
Rails version 2.3.8
I have a ticket model that has many comments
the comments have an attribute called "admin" -- is this a comment
added by an administrator
the ticket has an attribute called "admin_email_address"
I want to validate when saving the ticket and say "if I have a new
admin comment, make sure I have an admin_email_address"
In my ticket model, the
2010 Oct 31
4
Newbie - Rails 3 authentication question (Devise)
Hello!
I''m working on my first Rails app and I have a question regarding
authentication. I already have authentication for signing up, logging
in, logging out, etc. What I need is an account email activation
function and a reset password (forgot password) function. I have read
a little bit about Devise and watched the Railscast episodes on it, it
seems nice, but is it possible to add
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 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 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,
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 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
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 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
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.
2007 Jun 02
7
I''m really bad at controllers, help please.
Hey,
Sorry for so many questions - I''m really bad at this right now.
I''m trying to cover the following code w/ rspec
def index
if params[:user_id]
@user = User.find(params[:user_id])
@messages = @user.messages
end
end
So basically what I''m doing is listing all the messages for a user,
provided there is an id parameter.
describe
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
2006 Apr 05
13
scaffold misuse?
Running ruby script/generate scaffold Product Admin
is a wonderful way to set up well, exactly what it says, a scaffold.
My problem is that I have several other tables that are linked,
through foreign keys, to the Product table. Say an "authors" table.
Now when I go enter a new product, a book, I want the application to
provide a drop down list of authors generated from the records in
2011 Aug 11
17
f.collection_select: what are the parameters?
The rails docs are so horrible on the collection_select method. They
need to show a *complete* form, and show two examples: one that calls
f.collection_select(), and another that calls collection_select(), and
explain the differences.
Given this line:
f.collection_select :topic, Topic.all, :id, :category
What the !@#$!@#$ is :topic?
--
Posted via http://www.ruby-forum.com/.
--
You received
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
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
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
2012 Oct 23
0
route problem
Hello
I have this routes.rb
Tamara::Application.routes.draw do
ActiveAdmin.routes(self)
devise_for :admin_users, ActiveAdmin::Devise.config
resources :users
resources :category do
resources :berichten
end
end
So I thought that localhost:3000/<category>/bericht/new I could write a new
bericht which is stored in the <categoryname>
But when I look at rake routes