Displaying 20 results from an estimated 800 matches similar to: "update entry in a has_many relation"
2006 Jun 29
6
Naming Convention for Controllers?
Hello!
I just read DHH''s presentation pdf.
In his examples, he wrote PeopleController instead of PersonController.
I''ve been using singular words in controller''s name.
Which is more common?
Thanks.
Sam
--
Posted via http://www.ruby-forum.com/.
2007 Jun 05
6
Help with spec controller
Hello,
I haven''t been able to create a controller spec.
You can see the code here:
http://pastie.caboo.se/67980
The error message I''m getting is:
Spec::Mocks::MockExpectationError in ''PersonController should tell the Person
model to create a new person on POST to create''
Mock ''person'' received unexpected message :save with (no args)
2006 Mar 30
2
acts_as_ordered plugin
Hey all,
I''ve just put together a little plugin to easily access the neighbours of a
given model in a particular order. Read on if interested.
Install:
script/plugin install
http://svn.viney.net.nz/things/rails/plugins/acts_as_ordered
Usage:
class Person < ActiveRecord::Base
acts_as_ordered :order => ''first_name''
end
Say you have people with first
2007 May 29
5
Trouble defining a stub method for a controller
Hello,
Not sure if I am doing something really wrong (let''s not say
stupid for now), but I haven''t been able to stub a controller method
like:
controller.stub!(:logged_in?).and_return(true)
Please help, this is driving me nuts ;-)
--
An?bal Rojas
http://www.rubycorner.com
http://www.hasmanydevelopers.com
2006 Jun 01
1
link_to_remote renders Ajax.Updater, sometimes Ajax.Request
I''m new to Rails, but am really enjoying working with it.
But i just hit a brick wall...
I have two link_to_remote tags in two seperate _whatever.rhtml files.
The targets of the updates are in edit.rhtml which does a render
:partial to include the links. here''s some code:
<%= link_to_remote ''Destroy'',
:update => "libtable",
2005 Sep 29
0
:include doesn't respect :conditions of the included model
Hi all,
I have something like the following in my model(s)
class Person < ActiveRecord::Base
has_many :planung
has_one :last_planung
:class_name => "Planung",
:conditions => "exist IS TRUE",
:order => "date DESC"
end
class Planung < ActiveRecord::Base
belongs_to :person
end
And the corresponding
2005 Jun 24
0
lighttpd - sporadic mysql errors
I''m getting a strange error in the production.log (I''m on a TxD shared
server). The first entry is a successful request from right after
restarting lighttpd and killing all the procs, the second is the error
after accessing the site half an hour later without having changed
anything. Restarting lighttpd resolves the issue. What might be going
on?
2006 Jul 10
4
Session variable data validation
I''ve been using rails for about a month and I''ve been noticing that most
of my controller functions use values from my session variable. I find
that I write something like:
person = Person.find(session[:person]
if( person )
# ...
else
flash[:notice] = "unable to retrieve person"
redirect_to( :action => index )
end
It seems redundant to write similar code for
2008 Mar 10
2
New rsync option checksum-path
This is a suggestion for adding to rsync an option "--checksum-path=PROGRAM".
Once this option is given, provided it is accompained by option
"--checksum", both the receiving and sending side of rsync would
compute checksums calling PROGRAM, instead of the usual checksum
program.
Why is this usefull? Suppose I have two collections of MP3 files at
different locations which I
2006 Jul 07
0
has_many relation handling
Hello,
please have a look at this:
My tables:
create_table :languages do |t|
t.column :name, :string, :limit => 3
t.column :title, :string, :limit => 30
end
create_table :categories do |t|
t.column :category_id, :integer (3.)
t.column :created_at, :timestamp
t.column :updated_at, :timestamp
end
create_table :categorytranslations, :id
2006 Apr 24
0
Updating a form containing array of text fields with has_many/belongs_to relation?
I''ve got a User class and an Employer class set up as follows:
User.rb:
has_many :employers
Employer.rb
belongs_to :user
My tables are as follows:
mysql> select id,first_name,last_name from users limit 5;
+-----+------------+-----------+
| id | first_name | last_name |
+-----+------------+-----------+
| 711 | Patrick | Stewart |
| 714 | Larry | Davis |
mysql>
2006 Apr 30
1
Callbacks on has_many relation
Hello,
Is there a way to implement a callback for somehting like before_add and
after_ad on a statement like this with a has_many relation?
x.children << Item.create(:title=>"test")
I want that x has a callback that is called when the item is added.
I found something in
2011 Nov 03
0
Arel table aliases and ActiveRecord::Relation help: how to specify "multiple has_many items in a query"
What is the recommended way to use table aliases with
ActiveRecord::Relation these days?
In prior versions of Rails, this would work:
assume (pseudo code):
model A
has_many b''s
model B
,,,
at = B.arel_table
atalias = at.alias(at.name + "_1")
A.join(:b).join(atalias).where(atalias[:a_id].eq(at[:a_id]).where("b.widget
=
2006 Jul 11
4
checkboxes with a has_many :through relation
All,
I''m populating a view with checkboxes in a list. I want to be able to
assign to my has_many relationship using the post values of these
checkboxes. Essentially, I want to populate the relationship table
which will create the correct join values in my model.
Here is my check_box_tag code:
<%= check_box_tag("@current_job[target_list_ids][]",
2006 Apr 29
2
Seeing performance problems with has_many :through relation
Greetings all, I am looking for some insight from some of the more
experienced with has_many :through relationships as I am having a hard
time reconciling the performance I am seeing.
I have 2 tables that are linked together via has_many :through
Table 1: urls ( there are about 7,000 records )
2 fields, id and url
Table 2: phrases ( there are about 87,000 records )
2 fields, id and phrase (w/
2005 Feb 24
8
web services with ActionWebService
<noobalert>
Uh, yeah. So my noob self is showing through again. I''m trying to
write a simple hello-world type web service with the ActionWebService
thingy. I didn''t get very far. I''ve only done web services stuff in
.NET, so I''m not exactly used to this sort of thing.
Anyhow, I have a file, person_api.rb in my app/apis folder. I want to
take a single
2005 Mar 04
3
optimization
Ok, so, I''ve written my first app in rails. It''s pretty nifty. Only
one problem. Slower than you could possibly comprehend.
Processing PersonController#show (for 67.138.254.231 at Thu Mar 03
21:04:16 Eastern Standard Time 2005)
Parameters: {:id=>"1", :controller=>"person", :action=>"show"}
[4;35mPerson Load (0.219000) [0;37mSELECT
2006 Jun 26
0
Update_attributes working, or not? I can''t tell.
I have a basic login system implemented. I''ve recently added a
timestamp field "last_activity_time". During the login process, if I
successfully get back a user object, I do this:
user.update_attribute(:last_activity_time, Time.now())
It appears to be successful given the breadcrumbs I''ve strewn around it,
but nothing gets written out to my table. In
2006 Apr 20
3
has_many :through with has_many/has_many join models
It seems that using a join model that joins with two has_many''s will
fail to generate proper SQL
class StudentSemesterRecord < ActiveRecord::Base
belongs_to :semester
has_many :discipline_records, :through => :semester
end
class Semester < ActiveRecord::Base
has_many :student_semester_records
has_many :discipline_records
end
class DisciplineRecord <
2006 Jul 23
4
has_many AND has_many :through ?
Hi,
I am working on a scheduling app and I have a perpelextion (new word).
I am wondering if the problem is my data model
I have Users.
Users can create Events.
Users can be invited to Events created by other Users.
So...
user.rb
class User < ActiveRecord::Base
has_many :invitations # invitations to other users'' events
has_many :events, :through => :invitations # all events