ruby-on-rails

How to send "multiple" extra parameters on a link/button_to_remote call?

In this example, <%=button_to_remote "Get Related Users", {:url => { :action => 'get_related_users' }, :update => 'result',:with=>"'someVal=3'"} %> If I have to send one more key/value pair [someVal2=5], what will the :with look like? ...

Using redirect_to to :create action

I am trying to redirect to the create method of another controller. However, I can't find a way to set the method to POST. This results in the index method to be called. Using :method => :post just creates a new parameter, but doesn't change the http method. Any ideas how to redirect to the create method? ...

Undefined method `add' on a cucumber step that usually works.

I have a path defined: when /the admin home\s?page/ "/admin/" I have scenario that is passing: Scenario: Let admins see the admin homepage Given "pojo" is logged in And "pojo" is an "admin" And I am on the admin home page Then I should see "Hi there." And I have a scenario that is failing: Scenario: Review fl...

Email Verification plugin for rails?

Hi, I'd like to verify a user's email address by sending them a verify-email-message. Do you know of a good Rails plugin that they've used or seen? Since I didn't see anything good via Google, at this point, my thought is: Add a verified boolean field to the user model. Default false. After user is added (unverified), combine email w...

How do I completely uninstall rails, ruby and rubygems?

My system is F'd. How do I completely uninstall rails, ruby and rubygems? any suggestions on where to go to reinstall from scratch? Best practices? I'd like to get back to 3.0 beta Thanks! ...

Changing ActiveRecord attribute value in before_save hook

I needed to fix the encoding of an ActiveRecord attribute and decided to do it in a before_save hook. And at this point I noticed an unexpected feature. When I wanted to change the value of the attribute, simple using the attribute_name=XY did not work as I expected. Instead of that I needed to use self[:attribute_name]=XY. So far did no...

Rails: distance_of_time_NOT_in_words

As in, distance_of_time(Time.now, Time.tomorrow).days = 1 or something along those lines? If not, what would be a good way to achieve this? I know there is "from_now" but why wouldn't there be a from_whenever? ...

How can I use friendly ID in Rails like mysite.com/[USERNAME]

How can I use friendly URLs on my Rails application ? All I need is to make available the following url format mysite.com/company1 mysite.com/user123 mysite.com/user1234 mysite.com/newton.garcia mysite.com/company-name Can anyone help ? ...

Problem running RoR app in production environment

Have an app that has "listings" - think classified ads - and each listing has a list of tags. The following code fails when I run the app in production mode, but works fine under development mode uninitialized constant ActiveRecord::Acts::Taggable::InstanceMethods::TagList Extracted source (around line #45): 42: 43: <...

Array::include? on ActiveRecord collection not calling op== ?

Given a collection of named Foos from ActiveRecord, why does Array#include? not seem to call Foo.== but yet index does? class Foo < ActiveRecord::Base def ==(s) self.name == s end end class Bar < ActiveRecord::Base has_many :foos end bar.foos << Foo.new( :name => 'hmm' ) bar.foos.all.include?('hmm') # does select all from ...

When -exactly- does the Rails3 application get initialized?

I've been fighting left and right with rails 3 and bundler. There are a few gems out there that don't work properly if the rails application hasn't been loaded yet. factory_girl and shoulda are both examples, even on the rails3 branch. Taking shoulda as an example, when trying to run rake test:units I get the following error: DEPRECATION...

rendering specific fields with Rails

Hi, If I have an object say @user and I want to render only certain fields in it say first_name and last_name(I'm using AMF) render :amf => @user For instance I have a property for @user which is 'dob' (date of birth) I would like to use it inside the controller business logic but I don't want to send it to the client (in this cas...

How Can I switch the session storage according to the client on Ruby on Rails 2.3.5

Hi! I have a question about sessions on ruby-on-rails. We have a several options about session storage such as cookie, active_record_store, etc.. I primarily use the cookie storage, but, there are some client which doesn't support cookie function. In that case, I have to make that client to use the "active_record_store". My rails versi...

How to evaluate the string in ruby if the string contains ruby command?

In my case, I was storing the sql query in my database as text. I am showing you one record which is present in my database Query.all :id => 1, :sql => "select * from user where id = #{params[:id]}" str = Query.first Now 'str' has value "select * from user where id = #{params[:id]}" Here, I want to parsed the string like If my pa...

Group by with ActiveRecord in Rails

Hello, I have a the following table with rows: =============================================== id| name | group1 | group2 | group3 | group4 | =============================================== 1 | Bob | 1 | 0 | 0 | 1 | =============================================== 2 | Eric | 0 | 1 | 0 | 1 | ==...

Rails HTML editor to create forms

Hey all, I'm looking for a HTML editor which can be (easiliy) integrated in a RoR app that has the possibility to create forms. Not forms per se, but I need the possibility to add radiobuttons, input fields, checkboxes and so on. I loved the smoothness of TinyMCE, but apparently this doesn't take me far enough. Does there exists such a g...

Form is submitting when the page loads

I have a really simple Rails app. Basically an article with comments. I want the article page to show the article, comments underneath and then a textbox to write a comment and a submit button to submit it. I got it all working except for one (big) problem. When the page loads.. example.com/article/1 a blank comment is submitted to the...

group by country with ActiveRecords in Rails

Hello, I have a table with users: name | country | .. | UK | .. | US | .. | US | .. | UK | .. | FR | .. | FR | .. | UK | .. | UK | .. | DE | .. | DE | .. | UK | .. | CA | . . What is the most efficient way with ActiveRecord to get the li...

Graph Database in ruby ?

Are there any graph database in ruby . i have heard of neo4j in Jruby , Are there any pure implementation of graph database in ruby ? ...

Session bug using facebook-connect-with-authlogic in Rails

I'm trying to follow this article: http://ryanbigg.com/2010/03/testing-facebook, but I'm stuck. I think the problem is with my session, in that the current_usermethod comes up with nil for session[:facebook_session]. According to the original authlogic, it says to use the active_record_store for sessions: # config/environment.rb confi...