Displaying 20 results from an estimated 3000 matches similar to: "update_attributes"
2006 Oct 30
7
belongs_to nonintuitive results with assignment?
class Page < ActiveRecord::Base
has_many :lists
end
class List < ActiveRecord::Base
belongs_to :page
end
######### controller code, inside action:
list = List.find(params[:id])
old_page = list.page
list.page = new_page
# what is the value of old_page now?
old_page now is the same as new_page! what the heck?!?
The only thing i can think of is that old_page is
2006 Nov 09
2
redefining the method belongs_to in ActiveRecord::Base
Hi. I''ve tried to redefine the method belongs_to in ActiveRecord::Base,
so every time a model is defined as belonging to :attachment, it should
have some additional methods. I tried to do an alias of belongs_to, but
this was not successful. The error message in Webrick was
> Booting WEBrick...
./script/../config/../lib/ActiveRecordExtensions.rb:67: undefined
method
2006 Nov 04
2
Instant Rails 1.4 final released (with RadRails support!)
This is the final release for Instant Rails 1.4. It corrects the two
known problems with the preview1 release (two help menu items
caused Instant Rails to crash). Instant Rails 1.4 contains the following
major changes:
* Upgrades Rails to version 1.1.6
(other components upgraded to current release, also)
* SCGI has been replaced by Mongrel (using Apache''s
mod_proxy for
2006 Sep 28
2
RHTML page not rendering properly
I''ve got a weired problem. I got a RHTML page which is not rendered
properly in the browser all other pages in my app do renders correctly.
Only this one page returns the page''s HTML with the following header
Content-Type: text/html
Set-Cookie: _session_id=cb3c140fd4ef907c99ef203a053fba1a; path=/
Status: 200 OK
Cache-Control: no-cache
<html>
.....................
2006 Sep 29
2
ApplicationHelper is not a parent of SomeHelper?
i have:
# file application_helper.rb
module ApplicationHelper
def load_components
@right_sidebar = ''some stuffs''
end
end
# file user_public/blog_helper.rb
module UserPublic::BlogHelper
def load_components
ApplicationHelper.load_components
@right_sidebar += ''{blog archive}''
end
end
the problem is, i want to load the
2006 Nov 04
2
Possible to use attr_reader/writer in model?
I have some properties that I want setable externally, but readable only
internally. I''ve played around with attr_writer (and attr_reader
separately) but can''t figure out how to get either to work. I can do
what I want using attr_accessor, or just straight out defining the prop
setter method. Anybody know how to use attr_writer or attr_reader with a
model?
You da man,
Joe
2006 Sep 03
2
Undefined method "xxx" of a model when calling a helper
Hi all
I''m creating a shop page. I have a cart model that looks like the
following:
class Cart
attr_reader :line_items
def get_line_item id
@line_items.each do |l|
return l if l.id == id
end
end
def initialize
@line_items = []
end
def empty!
initialize
end
def empty?
return true if @line_items.empty?
false
end
end
And I have some
2006 Sep 04
2
"include" versus "extend" - what's the difference
Hi,
Just wondering when one would use "include" over "extend"? Both seem to
bring in methods to the class no?
The context is I''m just trying to understand why both are used with the
acts_as_audited plugin:
Full extract from plugin (used within here):
==================================================
# Copyright (c) 2006 Brandon Keepers
#
# Permission is hereby
2006 Aug 30
10
respond_to not detecting JS turned on. form_to_remote problem?
I''m trying to use respond_to to redirect visitors who have JS turned off to a different page. The problem I''m having is that respond_to is sending *everybody* there. It''s not recognizing that JS is turned on in the browser. The wanted_html.rhtml file below is rendered whether I''ve got JS turned on or off. I''ve looked at the Accept headers being sent
2006 Jul 30
8
Method_missing from Ruby for Rails book
I''m having a problem getting this example from the book to work:
class Cookbook
attr_accessor :title, :author
def initialize
@recipes = []
end
def method_missing(m, *args, &block)
@recipes.send(m, *args, &block)
end
end
cb = Cookbook.new
cb << recipe_for_cake
cb << recipe_for_chicken
beef_dishes = cb.find_all {|recipes| recipe.main_ingredient ==
2006 Aug 08
12
delete_if doesn''t work for has_and_belongs_to_many
I''m using Rails-1.1.4 with Ruby-1.8.4
So let''s say I have 2 model classes:
class Item
has_and_belongs_to_many :things
end
class Thing
has_and_belongs_to_many :items
end
i = Item.new
i.things << Thing.new( :value => "Something").save
i.things << Thing.new( :value => "Something Else" ).save
i.save
Fine, now I have two records in the
2006 Jul 17
14
REST Relationship Models
I''m trying to figure out an elegant way to do this:
I have the following three tables:
people, employer, employees
And consequently the following three models:
class Person < ActiveRecord::Base
end
class Employer < ActiveRecord::Base
has_many :employees
end
class Employee < ActiveRecord::Base
belongs_to :person
belongs_to :employer
end
I want to be able to say:
2006 Jul 31
2
[UPDATE] More info on RubyConf 2006 registration
Hi --
Registration for RubyConf 2006 is still scheduled to open on August 2,
in the early evening Pacific (US West Coast) time.
Also, there''s more info at http://www.rubycentral.org/conference
(e.g., the fact that this year we''re only taking credit cards, etc.).
David
P.S. Any LA area Rubyists around? I''ll be there this week doing Rails
training.
--
2006 Jul 26
2
newbie - HABTM confused...
I have a users table. I have a assignment table. and I have to log in
to see my assignments. i can and I hasve a session id.
I can make a new assignment and save my id in the user_id field of the
assigment table.
I want to share my assignments. so I can create a assignments_users
table. this way I can have assignment 1 shared with user 1 and 2. and
If I log in as user 1 or 2 I see the assignment.
2006 Aug 08
1
form parameter
How can I change some parameters in a function of the controller. I have
a User_Controller, who''s responsible for update the information fields
in the database.
The parameters are "id", "firstname" and "lastname". Now, I want to
manipulate parameter "lastname", because I would like to add at the end
a point.
>> Thomas Miller
2006 Aug 10
6
Partials - asked before never got reply
I''m trying to figure out how multiple partials in one page would be
configured when they are based on some action in the controller.
As an example -
I have a main/welcome page. If someone new or a user not logged in
arrives at this page I display both a registration form and a login
form. However, if they are logged in then those forms should not show
up on that page. Also should
2007 Aug 09
7
Integrating polymorphic models into controllers views? how?
I''m having trouble trying to get this to work.
How the heck do you get a polymorphic controller to work? Especially
integrating it with a view?
Let''s say that we have shows, and episodes, then comments.
A show has many episodes, an episode has many comments.
the route is /shows/1/episodes/1/
Now to add a comment to that episode, how would I do it? Let''s say
that the
2006 Jul 11
4
Variable Losing it''s Value
I fired up my rails app after a few weeks, only to find it was broken,
in that the variable seems to be losing it''s value somewhere between the
controller and the view. I''ve broken it down to the absolute simplest
test, and here is what I get:
THE CONTROLLER (controllers/visits_controller.rb)
class VisitsController < ApplicationController
def list
@test = "test"
2006 Jul 12
12
pass hash as parameter
Hello,
How can I pass a hash as parameter from a template with url_for?
e.g. : if I have
test = { :a => "a", :b => "b" }
How can I pass that with my request? Is it possible to pass nested
hash''es to?
Right now,
url_for :action => :test, test
doesn''t seem to work.
Thank you,
--
2006 Jul 12
5
DRY version of RoR book PAYMENT_TYPES example
In the book there is an example how to convert DB payment value to more
readable from. PAYMENT_TYPES array is defined and then in your views you
can use it as Order::PAYMENT_TYPES.
The problem is: how should I convert DB values (for example with type
char(1)) to full string representation. I know that I can add a Hash to
a model: IM = {''S'' => ''Skype'',