similar to: Possible to use attr_reader/writer in model?

Displaying 20 results from an estimated 1000 matches similar to: "Possible to use attr_reader/writer in model?"

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,
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/.
2006 Jan 15
4
form inputs resetting on sumbit
I searched for forum for something about this but couldn''t find anything. For example I have this in my view: (you enter start/end dates from dropdowns, pick a category and a report is generated.) <%= start_form_tag :action => ''display_report'' %> From: <%= date_select ''report'', ''date1'' %> <br /> To: <%=
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: >>
2007 Dec 14
4
find IP address of device on network based on MAC address
I have a device on my network that is not DHCP and I dont know the IP address of it and it has not method of finding it or changing it unless you know the IP address (setable by browser). Is there a way on linux, based on MAC address, to get the IP of the unit? Thanks, Jerry
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
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
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 Jan 12
1
A really newbie question
Hi, I have been playing around with Ruby after reading so much about it, and so I started tweaking with auto generated scaffold. But it seems like I must be missing something, can someone else please help me take a look and give me a couple pointers? In short I was trying to make a class User that has a method addupdate with 2 parameters (alias and email) which would either update the
2006 Jan 11
1
logger in my classes
Hi, I wrote a class which is not an AR extension, nor a controller. I''d like to use logger.* methods there too. My class is in lib/ dir. I include it in environment.rb with the line require ''lib/localization'' just after the line require File.join(File.dirname(__FILE__), ''boot'') I tried many ways to reuse the logger class. The cleaner way seemed to
2006 Sep 05
5
cattr_accessor
Hi, i''ve been playing with ror for a little over two months now, and was wondering wether someone could explain to me what was cattr_accessor and if it is still in use. . . i looked up in api.rubyonrails.com and coulnd''t find any documentation... is it a useful/worth learning method? what do u use it for? -- Posted via http://www.ruby-forum.com/.
1997 May 30
1
R-beta: auto save
I'm just about to put an autosave feature into R as per requests by Peter and Kurt. My current thinking is that it should be an option so that it is setable (in the profile if you want). One simply specifies the number of commands that are executed between calls to save. It won't be incremental; I'll just dump the output of ls(). I think that the file name should not be .RData but
2006 Jun 16
2
News posting system without a database
I need to create a news posting system without the use of a database. I''m going to create a file for each news post and have the view post each file in a specific directory as HTML. The newspost will contain: 1. A title. 2. A date. 3. The body. In the text file, I want line 1 to be the title, line 2 to be the date, and everything from line 3 on down to the be the body. What method
2005 Nov 15
3
Defining a variable in the environment and using it in controllers and views
Hi, I wanted to define a global variable in environment.rb like this: @pagemeta = {:title => ''Default page title'', :description => ''Default page description'', :keywords => ''Default page keywords''} And then, in a controller, override one or several of its values (like @pagemeta[:title] =
2007 Jan 09
1
assert_redirected_to not working as expected
I''ve installed the "acts_as_authenticated" plugin and made some modifications to the controller (app/controllers/account_controller.rb) "signup" module as follows: === def signup @page_title = ''Create Account'' @user = User.new(@params[:user]) if request.post? if @user.save session[:user] = User.authenticate(@user.login,
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All, I''m having a hell of a time figuring out what is going on here. I''m trying to override one of my getters so that I can format it a certain way in my form. But I can''t seem to get text_field to call the appropriate method on my object. So here''s my getter: public def FAX fax = read_attribute(:FAX) puts fax
2007 Sep 03
7
relationing has_many, belongs_to
Hello, i want to know if i am relationing fine, because i am having problems,i have 2 models, one for members and other to relate some members to this: class Member < ActiveRecord::Base has_many :matrix, :foreign_key=>:parent end class Matrix < ActiveRecord::Base set_table_name :matrix set_primary_key :userid belongs_to :member, :foreign_key=>:userid acts_as_tree
2013 Jun 25
0
attr :location_string
Hi, I have come across attr :location_string inside a class definition in Rails application. class Web < class Params attr :location_string def .... end .... end I know how attr_accessor, attr_reader or attr_writer works. But I don''t have any idea on attr in Rails. Can you kindly explain what it does? Thanks, Christopher -- Posted via http://www.ruby-forum.com/. --
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 18
1
CentOS 6.4 kickstart bonding
Hi all, Someone played with kickstart bonding with centos 6.4 ? CentOS 6.4, as upstream now support ifcae bonding in kickstart network section. I've an issue with configuring a second bonding iface in kicstart on CentOS 6.4. The first bonding (bond0) works as espected but the second is not configured during installation. I've a 6 nic server (two for "puclic" network, two for