Displaying 20 results from an estimated 200 matches similar to: "Trouble with has_one"
2006 Oct 07
3
blog_id magic with typo
Hi All,
I am modifying typo so as, I can host multiple blogs on the same typo.
And its almost done, except that...i am stuck at one place.
When a user posts a new article, depending upon current blog_id, I
would like to set the blog_id attribute of @article object.
So..in the admin/content_controller.rb:
We have:
def new_or_edit
    if request.post?
      set_article_author
     
2006 Jan 31
4
Rails bug? Conditions on associations ignored by eager loading
I''m looking for someone to confirm the following as a bug in Rails  
1.0 before I post it to Trac.
If I use eager loading on an association that has conditions defined,  
the conditions are ignored.
The following example illustrates the problem. I have two tables:
   create_table "blogs", :force => true do |t|
     t.column "name", :string
   end
   create_table
2006 Jun 17
4
ruby script/console fails to launch
Can someone please explain why I am see the following:
<snip>
rails/uploadimage> ruby script/console
Loading development environment.
/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require'': no such file 
to load -- readline (LoadError)
	from /usr/local/lib/ruby/1.8/irb/completion.rb:10
	from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules''
	from
2011 Mar 12
1
Black edges of the buttons and toolbars
how i can fix it? 
[Image: http://www.uploadimage.com.ar/images/38058064366679356935.png ]
[Image: http://www.uploadimage.com.ar/images/54354554174418943780.png ]
2010 Aug 15
0
Singular resources namespaced by its slug (Routing)
Hi,
I have the followed Rails 3 routes:
    Hello::Application.routes.draw do
      resources :blogs do
        resources :articles do
          resources :comments
        end
      end
    end
By raking them, we can find (for instance):
    GET    /blogs/:blog_id/articles(.:format)      {:action=>"index",
:controller=>"articles"}
Because every routes begin with the
2008 Oct 09
2
has_many validation the Rails way
Okay, this is something I run into a lot and don''t really have a great
solution.  Here is a simple example:
class Blog < ActiveRecord::Base
  has_many :posts
  validates_presence_of   :name
end
class Post < ActiveRecord::Base
  belongs_to :blog
  validates_presence_of  :name
  validates_presence_of  :blog_id
end
Now, if I want to create a blog and post at the same time I
2007 Feb 01
4
Automatically Indexing Associated Models
PROBLEM
I have two models, Blog and BlogComment. When a blog is initially
created, it has no comments. Upon creation, the title and body are
automatically added to the ferret index and directly searchable.
However, when a comment is added to a blog, that comment does not get
added to the index and is therefore not ferretable. The desired behavior
is that when a comment is added to a blog, that the
2006 May 27
0
Typo 1055 created_at Vs. published_at
[Couldn''t post this to the Typo forum, hope it''s Ok here :-)]
Before I go off and create a Typo ticket, I''d like to know if anyone 
else is experiencing this and what there thoughts might be on the 
subject?
In Typo 1055, if you use the admin interface and change the published 
date for an article, you will get "post not found", when you click on 
the article
2005 Dec 18
0
Caching question
I''ve got caching mostly working but it''s acting string with the index/home.
On the site I have a redirect the points http://nutritionreality.com at
http://nutritionreality.com/home
I do this in routes.rb by:
map.index '''', :controller  => ''home'', :action => ''index''
Caching happens on index (index.html gets created in
2006 May 30
3
Help about CMS - newbie in RoR
Hi team, I''m a very newbie RoR user from Spain and I''m developing a 
blog''s CMS. Why RoR?, coz I think it''s an amazing framework with many 
posibilities, portable and really powerful, with a young and optimist 
community, and taking my project I''ve prefered his structure in front of 
LAMP. Another thing is that I''ve liked to surprise my masters
2006 Sep 07
6
form_for - Child object - how to set parent id
Hi All,
I am just trying to learn ruby/rails so please don''t flame me if this is 
a stupid question.
As a learning project I decided to create my own blog using ROR. I have 
created a controller that shows paged blog entries, and below each blog 
is a list of comments along with a form alowing the user to add a new 
comment.
To create the form for the comment entry I used form_for
2006 Jul 24
7
[PATCH] Support for DB Clusters/Replication in ActiveRecord (RFC)
Skipped content of type multipart/alternative-------------- next part --------------
Index: connection_adapters/abstract/connection_specification.rb
===================================================================
--- connection_adapters/abstract/connection_specification.rb	(revision 4617)
+++ connection_adapters/abstract/connection_specification.rb	(working copy)
@@ -1,10 +1,21 @@
 require
2006 Nov 04
0
one to many relationship; has_one
I''m new to ruby and rails and as a result am a bit lost on implementing 
a one to many relationship.  In my DB I have 2 tables contents and 
locations, contents contains the foreign key location_id.  I generated a 
content and a location model using rails scripts and then edited the 
models as follows
class Content < ActiveRecord::Base
  has_one :location
end
class Location <
2006 Jun 19
0
has_one frustrations, please help!
Hi everyone. I''ve been bending my head around a has_one association for 
about 3 hours now and I can''t get it to work. I''m pretty sure it''s not 
something I''m overlooking anymore. Here''s the essential part of the 
schema I''m working with:
-----
t :topics
c :id
c :last_post_id
t :posts
c :id
c :topic_id
-----
Topics are simply named
2006 Jun 21
1
ActiveRecord has_one default value
My apologies if this is a dumb question, but I''ve searched around and 
haven''t been able to come up with a solution.
Is there a way when specifying a has_one association to specify a 
default value for an object if data is missing in the child table. For 
instance:
class Student
  has_one :university
end
if no university is associated to the student in the database, I would 
2006 May 16
1
saving a has_one association question
Hiall,
Say I have
class User
  has_one :community
end
class Community
  belongs_to :user
end
Will the following work and both save user and community if validation
doesn''t fail?
user = params[:user]
user.community = params[:community]
user.save
Or do I have to do something like the following
user = params[:user]
if user.save
  user.community = params[:community]
end
to be on the
2006 May 24
5
where can i find a good tutorial for has_one and belongs_to?
thanks for helps!
-- 
Posted via http://www.ruby-forum.com/.
2006 Apr 07
2
has_one not using the pk?
Hello,
im trying to wrap a fairly ugly legacy schema using AR. How to handle
normalized informations which aren''t connected via the pk?
create table what (
  myid int,
  myclass int, ;; references blahclass.blahid
  mygender int
)
create table blahclass (
  blahid int,
  mdesc1 text,
  fdesc1 text)
)
I would like to wrap this as
class What < AR::Base
  has_one :blahclass
class
2006 Apr 12
0
Sorting with SQL for has_one, belongs_to relationship
I''ve been using this sort helper to have sortable tables.
http://wiki.rubyonrails.com/rails/pages/Sort+Helper
I''ve encountered a situation where I need to sort a column that is not
part of a table, but it''s related table.
For example, say I have db tables called foos and bars. Foos have
fields called name and title. And bars have fields called note and
foo_id. Foos
2006 Apr 15
1
Is this a HAS_ONE bug?
Let''s say I have:
A BELONGS_TO B
B HAS_ONE A    (with :dependent=>:nullify)
But this association does not need to exist.  In other words, I could 
have many A''s and B''s that are not associated in this manner.
Presently, if I try to delete "B":
1. If B is associated to an "A", this works fine and A.my_B is 
nullified.
2. If B is NOT associated, I