ruby-on-rails

How to make Ruby on Rails RESTful routes pretty and human friendly?

With Ruby on Rails, REST is a great concept in terms of simplifying things for the developer and making resources easy for machines to access, but it also produces phenomenally ugly URLs for humans. For example, using the popular RESTful Authentication plugin to handle user login and authentication, it creates two controllers for authen...

Assigning Each User a Unique 100 character Hash in Ruby on Rails

I have a form on a website that takes in some personal information from the visitor. I'm passing this information to another service and I need to assign each one of these form submits a 100 character unique hash to be stored in the DB with the record. What's the optimal way to generate this key and make sure it's unique? It's okay if...

Encrypting Parameters accross controllers

I need to pass a parameter from one method in a controller to another. From my understanding I have to pass the parameters as a GET exposing it in the url string. What is the best way to encrypt the data so no one can see what is actually getting passed in the string? Also, is there a way to pass it via POST or is my original understa...

ActiveRecord has_many where two columns in table A are primary keys in table B

I have a model, Couple, which has two columns, first_person_id and second_person_id and another model, Person, whose primary key is person_id and has the column name Here's the usage I want: #including 'Person' model for eager loading, this is crucial for me c = Couple.find(:all, :include => :persons)[0] puts "#{c.first_person.name} an...

Configuring Postgres in Ubuntu 9.1 Rails dev-box for Cucumber testing...

I'm trying to install Postgres 8.4 for a Rails dev-box and I'm having a couple problems. I installed postgres and pg-admin3 through apt-get. Using the lastest Rails 2.3.5 and lastest Ruby 1.9.1 Now the configuration is bothering me. I found some documentation regarding setting up the user for the postgres user(which is the default adm...

Are there any authentication plugins that work with DataMapper?

I'm in need of an authentication method that works with DataMapper. I can see that the authlogic plugin requires the fields crypted_password, password_salt, persistence_token in the User model. Is it enough to just add these fields to the User model definition using DataMapper? ...

Ruby on Rails: joining two tables on something other than the standard foreign key

I have a rails query like: @user = User.find_by_username(params[:search], :include => [:user_similars]) Models: user (has_many :user_similars), user_similar (belongs_to :user) The user_similars mysql table has a "user_id" field as a foreign key, but I don't want :include to join on that for this instance. I'd like to join on...

How limiting are web frameworks

Hi, This is a general question about how limiting are web development frameworks such as Django and ruby-on-rails. I am planning on building a RESTful web service which will have a purely JSON/XML interface, no GUI. The service will rely on a database however for a few of the more important operations there is no clear way of persistin...

complicated installation spagetti of latest Rails 2.3.5

Hi, the basic and, I guess, more rhetorical question is why RoR installation/maintenance became so F%#$ing complicated? Some background of the problem: Platform: Windows XP Ruby version: 1.8.6 A few dozens gems installed with gem version 1.2.0 Current Rails version: 2.1 I just wanted to update to rails 2.3.5 thinking that I have a mode...

How do I access hidden columns from ActiveRecord (in informix)

Many databases have a hidden primary key column. MySQL implements this as _rowid. In MySQL's case it is really a pointer to a previously defined primary key column. However in other databases (in my case, Informix), this column is independent of a deliberately defined primary key. The database which I'm coding for was designed mostly...

What DataMapper plugin gives :null property option

I'm trying to adapt a piece of code that has: property :email, String, :index => true, :null => false, :length => 1000 in the model definition. I'm getting this error: ArgumentError: options :null are unknown from /usr/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/property.rb:901:in `assert_valid_options' from /usr/lib/ruby/ge...

onComplete for Ajax.Request buggy with cached content

I have a Ajax.Request in which I use onLoading and onComplete to show and hide a load animation gif. The problem is that every 10 clicks or so, the load animation fails to hide and just stays there animating even though the ajax request has returned successfully. I have a number of div elements that each has its own respective load anim...

Is it possible to have ActiveRecord and DataMapper use the same database in the same app?

I'm in the process of replacing ActiveRecord with DataMapper in one of my apps. Since there aren't any authentication solutions that are compatable with DataMapper, I'm thinking that I could use ActiveRecord just for user authentication, and then use DataMapper everywhere else. I'd like to have both ORMs interacting with the same databas...

Prototype Toggle through Array Only Toggling Last Item

I'm a beginner and my brother has showed me some prototype. All the weeks successfully toggle the last week in the array but no other. Please let me know if I need to be more specific! Thanks! <%= @athletic_program.program_name %> <br> <br> <% array of_ids = Array.new %> <% @program_weeks.each do |program_week| %> <% array_of_ids...

how to omit something from an rspec controller test?

In my RSpec controller test, I'm trying to test a particular action that makes a call to a subfunction. But I don't want the test to include the call to that subfunction. (it'll raise an error that simply cannot be fixed in my dev environment) What's the best way to omit this subfunction call from this controller action while I'm ru...

Rails: Where to place plugin files

I am relatively new to Rails and recently found a couple of useful gems like authlogic that will help in getting the project up and about really fast. However, I have been wondering where to place the model, view, and controller files that are dependent on the plugin, but are core concepts of my project. For example, is it better to pla...

Validates uniqueness of :link

Hi, I have a url field named link in my model with the following validation validates_uniqueness_of :link, :case_sensitive => false When I put "http://stackoverflow.com", it goes well. Now when I put "http://stackoverflow.com/" (with the trailing slach), this is also accepted as unique. But I want it to be invalid though there is "/" ...

How to get Radius tags parsing FBML correctly

I am using the Radius Tag System (from the RadiantCMS) for a content engine in my current applciation. Everything has worked really well, but now I am experiencing issues when using FBML inside my content. When I supply a tags like the following to my template: <fb:profile-pic uid="loggedinuser" size="square"></fb:profile-pic> Radia...

Is there timezone offset bug in ruby on rails?

I'm in Korea. Rails version is 2.3.5 in my environment, config.time_zone = 'Seoul' config.active_record.default_timezone = 'Seoul' created_at and updated_at value is inserted with local time in database. but, when I access model.created_at or model.updated_at, the value is understanding with UTC +9:00 So, I insert model to da...

Is there any command to check what plugins I am using in my RoR application?

Can I use any command to check if my application is using any plugins or not? ...