similar to: attr :location_string

Displaying 20 results from an estimated 10000 matches similar to: "attr :location_string"

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 Mar 31
1
dumb question: what is attr_xxxx
i''m very new to the rails scene and am seeing lines of code like attr_reader, attr_writer, attr_accessor, etc... and have no idea what they do. reading the section in the book i''m reading that explains the previous block of code says nothing about it really. -- Posted via http://www.ruby-forum.com/.
2007 Mar 21
2
A real puzzler: attr_accessor / create incompatibility?
Greetings, I have a problem with attr_accessor and create seemingly being at odds with each other in my environment. Here is the setup: A simple class representing a US State (say, Maine for example): class State < ActiveRecord::Base attr_accessor(:name, :code) end In an IRB session, I type the following and receive the response included below: >>
2006 Jan 09
1
Saving an upload
I am creating a database for movies (films) and television shows (shows) that will have has_and_belongs_to_many relationships with the pictures table. CREATE TABLE screenshots ( id serial NOT NULL, filename character varying NOT NULL, content_type character varying NOT NULL, primary key (id) ); CREATE TABLE films ( id serial NOT NULL, name character varying NOT NULL,
2009 Nov 27
2
attr_accessible & attr_accessor - what's the difference?
i''m still new to rails and working on digesting everything i come across. recently i came across these two. what is the difference between attr_accessor and attr_accessible? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2007 Jul 26
1
Lohan the observable
Sorry, that name is a misnomer. However, I was excited to find that Ruby has a built in Observable module and I''m pretty bored, so I apologize in advance.... require ''observer'' # one who is observed class Celebrity include Observable attr_accessor :name attr_reader :is def is=(val) @is = val changed notify_observers(self) end end # one who
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2008 Mar 04
4
Named collection forward fetching
Hello, I''m getting an "NoMethodError" traversing a named collection. Let me explain I have a named collection called best_friend in a class called user def self.best_friend find :all, :conditions => "designation = ''Best Friend''" end and if i do current_user.best_friend everything works great, I can pull up the user''s name as
2013 Sep 02
2
Why the string interpolation is not working inside the Nokogiri method `#search` ?
Why the string interpolation is not working inside the Nokogiri method `#search` ? require ''nokogiri'' doc = Nokogiri::HTML::Document.parse <<-eotl <div> <p>foo</p> <p>foo</p> <p>bar</p> </div> eotl doc.class # => Nokogiri::HTML::Document class Person attr_accessor :name end ram = Person.new
2005 Sep 07
0
model constructor errors.
I have a model; I do photo = Photo.new(parameters) parameters contains: {"picture"=>#<File:C:/DOCUME~1/BART~1/LOCALS~1/Temp/CGI3180.1>} so i expect that the def picture=(filename) method is called in this constructor.. this is not the case. Does anyone know why? params[:photo].each_pair do |id, parameters| photo = Photo.new(parameters) end class Photo
2014 Feb 19
0
Extending a module to models causes ArgumentError A copy of xx has been removed from module tree
How can I extend a module to a model class and use an instance of a custom class as a class instance variable for model such that when next request comes, custom class could be found and older instances are deleted? I created a class Samples. I also created a module LoadSamples where in a method say load_samples, I create a new Samples instance and assign it to a class instance variable. I extend
2006 Jun 26
0
DBI question. How do I load a database with data parsed from REXML?
I wrote a rexml script that parses rather big xml files (DOM parsing) and builds an object out of them. This is what it looks like after i parse the xml file and display the object: [#<Article:0xb79e7428 @brand="This is a story from ", @id=5337, @fblurb="burb", @ntype="news type here", @copy="Copyright \302\251 2006 ", @source="source",
2013 Dec 09
2
[PATCH] rework master-to-worker signaling to use a pipe
Signaling using normal kill(2) is preserved, but the master now prefers to signal workers using a pipe rather than kill(2). Non-graceful signals (:TERM/:KILL) are still sent using kill(2), as they ask for immediate shutdown. This change is necessary to avoid triggering the ubf (unblocking function) for rb_thread_call_without_gvl (and similar) functions extensions. Most notably, this fixes
2008 Feb 16
2
nil error?
Hi everyone, I''m sure I''m doing something stupid with this, so if somebody could talk some sense into me that would be great :) I''m trying to just increment a variable and I think I''m missing some basic concept (this is RoR 2.0.2 btw) So have a "players" table with several variables, including one called "odds". I''m using the
2006 Aug 12
10
adding extra variable to a class, how to access it?
somple question here but pretty confusing on my side. i have a model towns that is mapped to my towns table. can i add an extra variable to the class and access it in my view? basicall what i am trying to do is return a list of towns, and next to each town, display a total number of what i have in each town. ive tried both attr_reader and @total but no avail. here is my view <% for
2006 Feb 07
0
Rendering objects directly via <%= render @some_object %>
My original post might have been overlooked by most, but I''ve made a plugin (link below) which allows rendering of objects directly via the render method: <%= render @some_object %> which would actuall render the @some_object object (the object is even able to handle the options hash. Rendering would actually be handeled by the object itself, by leaving it up to the object to
2013 Mar 21
0
how to remove changed_attributes from yaml response
Hi, I am using attr_accessor attributes in model class and assigning the values to attr_accessor dynamically in controller. And am sending the data object to display in Yaml format. I am getting the response along with changed_attributes but I don''t want changed_attributes details in my response. build Model code class Test < ActiveRecord::Base attr_accessor: t_1, t_2, t_3, t_4 end
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 Apr 03
7
Getters and setters problem?
Hi list, first evening of playing with rails, so please forgive me if I ask something stupid. ;-) I created a User model and tried to use ActiveRecord callbacks to convert the password to sha1 just before saving it. For some reason postgresql gives me a error because the given password is null. To test even further I tried to change :login too, same error happens, :login is empty too. I am sure
2006 May 26
9
What syntax is this? belongs_to :Person
so when I''m reading the pick axe book second edition I don''t see anything like the syntax you see people using in rails code. Specifically when you see. belongs_to :Person has_many :Phones etc these are methods on ActiveRecord right? Why is this invocation syntax never described in the Pick Axe book? I do see things like attr_reader :some_attribute etc but you