Displaying 20 results from an estimated 3000 matches similar to: "not quite getting ajax to work.."
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 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 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 09
6
ajax effects
Hi,
i was wondering if there was some kind of general line of code i could
add to my application, anywhere i suppose, that would generate some kind
of effect to notify the user that an effect is happening...it could be a
box on the top of the screen or something, that would be like the small
bar at the end of the browser that shows the user the status of a
loading page ... i was hoping
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 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 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 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 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
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 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 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 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 Jun 28
2
Ajax - Upload File Upload
hello, i have a problem. I want to upload a file with ajax and the
following tag:
submit_to_remote ''button_save'',''Speichern'',{
:url => {:action => ''ajax_update'', :id => @product},
:update => ''formular''
}
it doesn''t work, my form_tag looks like:
form_remote_tag(:url => {:action =>
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