ruby-on-rails

Cucumber for PHP application

Is it possible to use Cucumber outside Rails? I'd like to start using it for testing some of my PHP applications, but I really don't know how to start. Probably the easiest way would be creating a Rails project only to run Cucumber features, but that seems like to me as overkill. What is the simplest way to set up Cucumber for testing ...

What is new in rails 3?

Couldn't find any compiled info on new things in rails 3. Nor release date. ...

undefined method 'add_acts_as_authentic_module'

Hi, i've added code config.gem "authlogic-oauth", :lib => "authlogic_oauth" to the environment.rb file in my app and got error undefined method 'add_acts_as_authentic_module' for ActiveRecord::Base::Class is there any solution to solve it? ...

How do you check the URL Helpers for a Model Resource in Rails?

I'm currently following the Shovell tutorial in the Simply Rails 2 book. On page 168, it mentions URL Helpers for the Story Resource: stories_path /stories new_story_path /stories/new story_path(@story) /stories/1 edit_story_path(@story) /stories/1/edit The above is then used in the contro...

how do I write that join query with ActiveRecord?

anyone know how I would write that query with AR? select *, (m.user_id=1) as member from band b join memberships m on m.band_id = g.id; Thanks in advance. ...

Does a "vertical" framework for RoR make sense?

I have been spending some time creating what I called a framework. It was aimed at the creation of quiz likes games. It was supposed to have two players syncronized and present them a question to solve, etc. I would like it to be fully customizable so I tried to develop components that can be put in or out of the pages. In the end th...

Generating URLs from form params in Rails

Is it possible to generate the url for the form submit based off of the values in the form? I am trying to create a search form that asks for the make and model <% form_tag make_model_search_path(:client_id => @client.id) do %> <%= select_tag :make, options_for_select(make_list) %> <%= select_tag :model, options_for_select(model_list) %...

Vendored gems not getting picked up by passenger

In my app, I've vendored the json-1.1.6 gem and in environment.rb file, its mentioned config.gem "json", :version => '1.1.6' When I try to access via browser, the following error is shown by passenger. Error message: can't activate json (= 1.1.7, runtime) for [], already activated json-1.1.6 for ["dancroak-twitter-search-0.5.5"] An...

SearchLogic + STI

Trying to implement a search logic search that uses associations with STI but I’m having a problem where it is not select the STI records as the subclass but the parent. Example: class Users end class Artist < User has many :agents, :through => :agents artists end class Agent < User has many :artists, :through => :agents artists...

Chris Pine = Ruby as X = Rails....What is X ?

I am just reading through Chris Pine's Learn to Program (The Ruby Series) 2nd Edition and it is one of the best programming books I have ever come across. Unfortunately, he hasn't written (or I can't find) a book for Rails. Does anyone know of any books that are of the same calibre and quality as Chris Pine's writing for Rails? Thanks...

RoR foreign key inside view and nil object

I'm working through Agile Web Development with Rails and having a problem with Task E and adding the payment types to a database. Within the orders table, there is a foreign key relating the column payment_type_id to the payment_types database (which holds columns id, label and value) So, an order has a payment_type_id of 1, which corre...

has_many :through, nested polymorphic relations

Is there a way to directly reference (using rails directly, without resorting to a lot of custom SQL) a relation that is nested behind a polymorphic relation? In the below example, is there a way to define a has_many relation in User that references LayerTwo? I'd like to do (in User) has_many :layer_twos, :through => layer_ones but...

RoR Lookup example

Hello. I have a very simple problem but cannot find a nice solution. I have a lookup code in ruby (for example, Students that live in a State): # State lookup (id, name) class State < ActiveRecord::Base has_many :students end # Class that belogs to a state class Student< ActiveRecord::Base belongs_to :state end and in the vie...

ActiveRecorded associated model back reference

Hello, It is easy to associate a model to another using has_many/belongs_to methods. Let's suppose the following models: class Movie < ActiveRecord::Base has_many :actors end So, I can find the actors from a given movie instance. But now, given an actor instance obtained through the actors association, I'd like to find the movie ...

Rails batch object creation for fixture?

I have a big list of record (something like 20, could be more) with a has_many :through relations, which is a bit complicate and it looks ugly on yml. Factory_girl doesn't seems to give me the simplistic ability to just create the fixture with a AR based script (it's a lot shorter that way) any good recommendation on what I could do? ...

rich internet application solutions for ruby

I am wondering what are the possible rich internet application solutions that goes well with ruby or if there is a GWT equivalent? ...

Remove the last 2 characters from a string in Ruby?

I'm collecting all my user's email addresses for a mass mailing like this: def self.all_email_addresses output = '' User.all.each{|u| output += u.email + ", " } output end However, I end up with an extra ", " on the string of email addresses. How can I get rid of this / is there a better way to get a comma separated list of...

Why to_xml on ActiveResource does not work well?

I have several ActiveResource model in my project. There was so strange to me when I called to_xml on my ActiveResource. The options that I passed to to_xml like :only and :except doesn't work at all. On ActiveRecord, it works really well. Anyone knows? class Node < ActiveResource::Base self.site = NODE_SERVER end # node has uuid, n...

Which is the best way to parsing RSS/Atom feeds with Rails

I'm developing feed reader application in Rails. And i'm new to feed. I've a some questions. Which is the best way to parsing thousand of RSS/Atom feeds with Rails or JavaScript /jQuery/ ? Is there any way to get just feed title / not load whole feed / ? Is there any way to get feed with limit ? Thanks in advance! How it works: htt...

Secure File Upload in Ruby On Rails

I built a photo gallery which uses Paperclip and validates the content-type using validates_attachment_content_type. The application runs on a shared host with Passenger. Is it possible to bypass the validation and run malicious scripts from the public/pictures directory? If so, is there anything that I can do to avoid evil scripts fro...