ruby-on-rails

restful route customization

How can i customize restful route urls to friendly urls like stackoverflow ? i have stackoverflow.com/questions/424/ and i want to have stackoverflow.com/questions/424/title-of-the-page ...

Rails: form.error_messages does not wrap custom validated fields in a fieldWithErrors div

I have a model that uses the low level validate_on_create method, based on a simple condition I'm adding an error message to the field, e.g self.errors.add(:expiry_date, "is too soon") if self.expiry_date && self.expiry_date < Date.today + 1.week When rendering the view 'new' after a failed save the field isn't picked up by error_mess...

Best book for getting up-to-speed on Ruby on Rails

I am planning to travel this weekend (long 23 hour flight) so my mission is that by the time I get off that plane I want to be able to start developing on ROR. I am very well versed in PHP/.NET/Java so I don't think picking up Ruby would be that hard. However, I would like to get some input from those who made the transit from PHP/Java ...

Rails: Best practice to store user settings?

Hi, I'm wondering what the best way is to store user settings? For a web 2.0 app I want users to be able to select certain settings. At the moment is it only when to receive email notifications. The easiest way would be to just create a Model "Settings" and have a column for every setting and then have a 1-1 relationship with users. B...

Karma/Reputation Plugin for Ruby on Rails?

I am looking for a karma (reputation) plugin or gem for Ruby on Rails. Preferably one that was integrated many of the best practices and research around the topic of community management & development. Any recommendations? ...

How can I make errors in HAML (Rails) show me the exact line where the error occurred?

NoMethodError in course_templates#index Showing app/views/course_templates/index.haml where line #6 raised: undefined method `new_course_template' for #<ActionView::Base:0x237c3e4> Extracted source (around line #6): 3: - content_for :sidebar do 4: %ul.links 5: %li= link_to "Add a Template", new_course_template(@provider) ...

Render different template based on where request was called from?

I'm calling a controller action to do a search with an AJAX request from 2 different pages and want to render a different rjs file based on which page requested the action. I could just make 2 actions to do this but it doesn't seem very DRY when it's the same code in the action just need different rjs as it's displaying the search result...

model class inheritance (problem with view)

Hello. I have 2 model classes with different attributes: class User < ActiveRecord::Base end class Subuser < User end When I call the 'new' function within controller: def new @subuser = Subuser.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @hosting } end end and try to access da...

merb callbacks equivalent in RAILS

Is there rails equivalents for : Merb::BootLoader.after_app_loads Merb::BootLoader.before_app_loads Merb::Assets::JavascriptAssetBundler.add_callback Merb::Assets::StylesheetAssetBundler.add_callback Thanks, ...

ActiveRecord, has_many :through, and Polymorphic Associations

Folks, Want to make sure I understand this correctly. And please disregard the case for inheritance here (SentientBeing), trying to instead focus on polymorphic models in has_many :through relationships. That said, consider the following... class Widget < ActiveRecord::Base has_many :widget_groupings has_many :people, :through => ...

conditional :confirm in link_to_remote

Hi. I have a Rails app where I was doing a general delete dialog with "are you sure" before it gets deleted. That's all fine, but I also have a small ajax on click to remove the block containing all the information. The block gets removed no matter what which makes things confusing. I couldn't seem to find any documentation online on how...

"Integration" between Rails' ActiveRecord and Java's Hibernate

Hi everybody: let me do a bit of "concept mining" here: I am involved in mantaining/extending an application whose functionality is distributed across several servers. For example, we have a machine running the ApplicationServer, another running the DataServer and so on. This application has a Web Interface. The current UI is totally im...

how does activerecord know to perform an insert or update?

maybe some ruby experts out there can shed some light on how activerecord know to do an insert or update when calling save(). what is the logic behind it? does it check to see if the primary key is blank or something and if so does an insert, if not an update? ...

How can I make an aggregated property support ActiveRecord::Dirty semantics?

I have an aggregated attribute which I want to be able ask about its _changed? ness, etc. composed_of :range, :class_name => 'Range', :mapping => [ %w(range_begin begin), %w(range_end end)], :allow_nil => true If I use the aggregation: foo.range = 1..10 This is what I get: foo.range ...

Paypal, Recurring Billing, and ActiveMerchant

Hello, I'm trying to research how to add a subscription based pay model on an existing site of mine, but am running into a lot of conflicting information and caused me to be a bit lost. All I need is a very simple way to set up recurring billing (per month) by credit card. I just need a simple solution, but am having a hard time findi...

ActiveRecord finding existing table indexes

I am writing a migration generator for a plugin I am writing and I need to to be able to find what unique indexes a table has so I can modify existing unique indexes to become a composite unique index. I have been trying to find a way to access what indexes a table has with ActiveRecord. I have only been able to find ActiveRecord::Conn...

Ruby (RoR) XML to hash and then show in views

Hey. I have some xml on server (http://server.com/my.xml). Here is the example: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE current PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <current> <song>Bruce - Inside The Machine</song> <song>02 Duel of the Fates 1</song> </current> ...

Rails Modeling Question - Relationships and Primary Keys

I'm working on a rails site that I've inherited and am trying to troubleshooting some sub-optimal model behavior. I have users, songs, and songs_download, each of which is its own model. Here's the relevant line from the users model: has_and_belongs_to_many :downloaded_songs, :class_name => 'Song', :join_table => :song_downloads F...

rails convert class methods to named scope

Hi all. Rails newbie here. I'm trying to get some class methods into named_scopes. My application structure is similar to a blog application with user comments. Each comment model has a score attribute determined by ratings made from other users. I want to be able to have a named scope that returns the top ten users with the largest tota...

What is the best CI server for Ruby on Rails Web Applications?

I want to use a CI (Continuous Integration) Server for my Ruby on Rails Application. If the application were in Java, I should use Hudson CI Server. What is the best solution in Ruby on Rails? ...