similar to: Method_missing from Ruby for Rails book

Displaying 20 results from an estimated 1000 matches similar to: "Method_missing from Ruby for Rails book"

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 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 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 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 16
17
AWDWR question
In an early section on Action View, showing code being put directly into the rhtml file: <% require ''date'' DAY_NAMES = %w{ Sunday Monday Tuesday Wednesday Thursday Friday Saturday } today = Date.today %> <h1>Hello, Dave</h1> <p> It''s <%= DAY_NAMES[today.wday] %>. Tomorrow is <%= DAY_NAMES[(today + 1).wday %>. </p> I get this
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 Feb 10
12
Accessing ''many'' variables
Hi, I have a class called Outlet which has_many Jacks. Apart from internal id, each jack is unique by the attribute ''color''. I''d like to iterate through each Outlet, and be able to output data for a Jack of a certain color. Say, I want to access the orange jack for the current outlet: <td><%=h outlet.jack.color[''O''].ip_address
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 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
2006 May 31
5
Help with sorting arrays with objects in it
I have to build an array through both activerecord and also through a ferret index. I was hoping to find a way of sorting the array as i combine the two so def advanced_search(search_text, store, format, sortby) # find items in ferret index items = Item.find_by_contents(search_text) # and now find all the items from a certain store or category items_from_sql = Item.find_by_sql("SELECT *
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'',
2006 Apr 27
5
ERb on he command line re: Ruby For Rails book
Hi, I am working thru the Ruby for rails book. On page 30 David Black talks about running erb from the command line i.e. $ erb erbdemo.rb just as you would a normal ruby prog ($ ruby erbdemo.rb) but when I try to do this I get command not found. How do I make this work? I am running Linux (Ubuntu Breezy) Regards, Paul
2006 Feb 10
15
"Ruby for Rails" in early access release
Hi -- My book "Ruby for Rails" is now being released one chapter at a time through the Manning Early Access Program, with the whole book due to appear on May 1. If you''re interested, see http://www.manning.com/books/black (I guess I could have just sent my sig with no body, but anyway :-) David -- David A. Black (dblack@wobblini.net) Ruby Power and Light
2006 May 11
7
[ANN/ADV] Ruby for Rails now published in paper!
Hi -- I''m on the road, so I haven''t laid eyes on it yet -- but word on the virtual street is that "Ruby for Rails: Ruby techniques for Rails developers" is now out in paper. It will probably take a little longer to trickle to your neighborhood Barnes and Noble... but you can order it now from the publisher. See http://www.manning.com/black. And trickle it will, too.
2006 Jul 20
19
Recipes versus Ruby for Rails: what''s best after Agile?
For expats from other languages, what''s the next best step after the Agile Web Dev book: Rails Recipes or Ruby for Rails? Thanks, -- Austin -- Posted via http://www.ruby-forum.com/.
2006 Aug 07
2
Getting an array of ids from form checkboxes?
Is it possible to set up a list of checkboxes so that the form parameters are given in an array (eg {"delete_list" => [3,6,7]}) ? At the moment I''m using <%= check_box_tag "delete_list[#{post.id}]" %> ...which gives parameters looking like {"delete_list" => {"3" => "1", "6" => "1",
2006 Jul 13
3
not quite getting ajax to work..
this might not be an ajax problem.. but i am stumped.. to cut out all the mess, here''s what i have a controller with this code: def test render(:layout => false) @data = params[:newOpp] end a partial which contains a form that has a button like this: <%= submit_to_remote("confirm","Confirm Entry", :url => {:action =>
2006 Jul 17
2
count and result
What is the equivelant of the following SQL in rails: SELECT person, count(person) as occurance FROM invoice GROUP BY person; This would give something like: Person | Occurance -------------------- Bill 1 Joe 15 Carlos 7 etc etc.. It seems the fx. Person.count(..) will only yield the actual occurance, but not listed with the actual person - and Person.find(..) will not
2006 Jul 19
1
Eval class
Hello I wanna create class on the fly, this class is generate in method, it need eval a class and instace a new object of this class. How i do it? Bruno -- Posted via http://www.ruby-forum.com/.
2006 Jul 09
2
filters
Hi, ...i''m fairly new to ruby on rails, so maybe this is a simple question, but i''ve been racking my wits for a while now, but i can''t figure out why this isn''t working... i''m implementing some kind of a questioniere, so that when a user picks a certain answer, the value of that answer goes into a session variable that stores the amount of points