ruby-on-rails

How can I order by attributes of multiple subclasses that inherit from the same base class in Ruby on Rails?

I have 4 classes - Patient, Doctor, Person, and Appointment. Patient and Doctor are subclasses of Person. Appointment belongs to Patient and belongs to Doctor. I want to write an AR statement to sort appointments by the patient's last name and another to sort by the doctor's last name, as all appointments will be in a sortable table. ...

Rails app deployed with Passenger just displays index of app's public directory

I am trying to deploy a Rails application on Ubuntu 9.04 using Passenger. As far as I can see, I have everything configured correctly; however when I point my browser at my domain, all I see is the index of the app's public directory. My hunch is that Passenger is not starting up - at the bottom of just-plain-folks.co.uk there's no ref...

Auto Refresh a page in Ruby on Rails

I am a newbie in Ruby On Rails, Can someone tell me how to refresh a page. Without any values submitted With previous values submitted ...

Include Account info in Users Database

Hi, I'm building my first Rail App and are beginning to setup my database. I have a simpel Users table containg name, e-mail (login), password and so on. The site lets the users bet each other (with monopoly money), so I need to add information about the users current winnings and other delicate matters to the database. Question: Sho...

Rails way to reset seed on id field

I have found the "pure SQL" answers to this question. Is there a way, in Rails, to reset the id field for a specific table? Why do I want to do this? Because I have tables with constantly moving data - rarely more than 100 rows, but always different. It is up to 25k now, and there's just no point in that. I intend on using a scheduler in...

Rails polymorphic assosication - on validation error render parent show action with flash message...

I have articles, profiles, and comments. There is a polymorphic association between articles/profiles and comments called commentable. On success creating a new comment I return to the commentable parent object with a sucess flash and I would like to do the same with the appropriate error flash on validation errors. What should I pass ...

One model - many DB connections in Rails?

(using Ruby on Rails and ActiveRecord) In short: Is there some way how a model can use different DB schema for each request? Why I need id: I have a working intranet application working for one company but I decided I would like to offer it to other companies. The Rails way would be to add company_id to each model and alway use this sc...

why ?format=csv files doest not have extension

I have a standard restful rails application. format.html { @users = User.find(:all, :limit => 10)} format.csv { @users = User.find(:all, :limit => 10) } When the url is http://localhost:3000/users.csv I get a file with name users.csv . However if the url is http://localhost:3000/users?format=csv then the file I get has name use...

Link_to instead of button to submit a form

Hi, I'm new at ruby on rails, and I wanted to accomplish the following: I've got a list with check boxes(one per row) and I'd like to have a link button(not a common button or submit) so when I click it I call an action from a controller. My questions are: How can I call a controller action with the link_to? How do I get the checkbo...

List databases/objects using Rails console

In Rails console: I was wondering if you could list/examine what databases/objects are available to you. Yes I know you can see using other tools, just curious if you can inspect them inside the Rails console. thanks. ...

rails assert_redirect_to

routes.rb map.resources :places do |places| places.resources :reviews end place model class Place < ActiveRecord::Base has_many :reviews end review model class Review < ActiveRecord::Base belongs_to :place end In my reviews controller test I have the following assert_redirect_to statement assert_redirected_to pl...

check value starting with decimal ruby on rails

How do I check a value starting with a decimal is_a_number(value) .... works for 12, 12.0, 12.2, 0.23 but not .23 Basically I'm doing a validation in a form, and I want to allow values starting with . i.e .23 but obviously pop up a flag (false) when its not a number ...

Building a mutliplayer game site

I am building a site that has a lot in common with a person-on-person chess site. I was thinking of using Rails for the front-end(User Registration, Navigation, etc) and something like Scala or Erlang for the engine(Game state and maybe AI). I was wondering - Is this a good situation to use that type of design? How exactly would be be...

Cache the output of an action on a per-format & per-user basis

Ryan Bates' render-caching gem is nice, but it keys cache entries by request_uris: def render_with_cache(key = nil, options = nil) key ||= request.request_uri # <---- body = Rails.cache.read(key) if body render :text => body else yield if block_given? render unless performed? Rails.cache.write(key, response....

Additional javascript keyboard shortcuts for wysihat

I'm working on a web application that uses wysihat to let the user edit a large textarea. I wanted a WYSIWYG text editor that was easily customized, and one of the customizations I was hoping to make was having a keyboard shortcut (I was thinking command/control + L) turn the current line into a heading. I can add buttons to do this ea...

Undefined method self.id in rails model

I have a simple Customer model which has id, firstName, lastName, address_id columns. In the method I have the following method to add data to the database: def self.add_customer(firstname, lastname) @cust = Customer.new(:firstName => firstname, :lastName => lastname, :address_id => self.id) @cust.save end This is giving...

Enable Web services in Redmine

Hi, Can any one guide me how to enable web services in redmine, specially XML RPC. And a proper way to implement such web service in redmine. Thanks. Parthiv ...

rails how to display data or retrieve values after find

I did a find on some model and got the following >> @addy => [#<Address id: 3, street: "Some Street", houseNumber: nil, created_at: "2010-01-20 06:09:52", updated_at: "2010-01-20 06:09:52", address_id: 16>] Now how do I retrieve the values? what if i want the street? @addy.street does not work netiher does @addy[:street] what if i ...

Best Approach to responding to jQuery Events in Ruby on Rails

I'm using jQuery to create an inline calendar with my Rails application. To respond to date selections jQuery calls a function in Javascript. In my application, I'm wanting to query the database with the date selected and then update data onscreen based upon the results from the query. What is the best practice to call a method from the...

"merging" multiple models. To create a "recent activity" box

How do you merge models so that I can have the last 10 Posts, Feed Entries and Private Messages displayed in order? Posts are stored in the "Post" model and ordered on "created_at" Feed Entries are stored in "Planet" and ordered on "published_at" Private Messages are stored in "Message" and need to be filtered with: :conditions => "r...