ruby-on-rails

RSpec can't find Cucumber gem

When running rspec I get the following error: no such file to load -- cucumber-rails /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `requi...

Best practice for handling two similar objects

Let's say I have two different controller/view sets that are basically identical. Business hours and Staff hours The first contains a business_id, the latter a staff_id. Otherwise they look the same. id, mon_start_time, mon_stop_time, tues_start_time, tues_stop_time, etc... 1) Is there a way I would use the same controller for these s...

Getting authlogic_facebook_connect to create users in DB

Hi all, I'm using the Authlogic Facebook Connect plugin on my site. After a bit of a struggle I can sign in with FBConnect, I can get stuff from the FBSession, like the users name, and I can logout. But, the README on the plugin site seems to suggest that following the five steps will result in the FB UID being saved in your local datab...

Trouble getting basic searchlogic plugin code to work in Rails App

To preface this I am a complete Rails newcomer so don't judge my lack of skills too harshly. Anyway, my rails app is throwing this error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id I am trying to make a basic form that will allow a user to search for a "match" by "country". It ...

Rails: How can I configure to routes.rb for /:id?

I am working on my personal site with RoR. I searched and read books. But I cannot figure out. How Can I configure routes.rb for xxxxx.com/:id? For example: twitpic.com's image url or short url is "http://twitpic.com/11u1cy". ...

Can prawn generate PDFs with links?

I need to embed a link into a generated pdf in a ruby on rails app. Is there a way to do this with prawn? Reading about this it turns out that prawn-format was the answer for awhile, but 0.7.x broke this. prawn-format uses the link_annotate(rect, options={}) function to create links. What options need to be passed into this to get it t...

use uploadify in ruby on rails

hi...i'm trying to use the jQuery Uploadify on a Ruby on Rails project. i am able to browse for a file, and select it. the upload progress goes till 100% and then i get a HTTP error. my development.log is below Processing ApplicationController#index (for 127.0.0.1 at 2010-02-07 18:33:01) [POST] Parameters: {"Filename"=>"file.psd", "fo...

Rails 'returning' method - One-liner to build Array from Multiple Arrays in Ruby?

How do I convert the following to a clear one-liner in ruby? def questions results = [] sections.each do |section| results = results.concat(Question.find_all_by_survey_section_id(section.id)) end results end I feel like I could use the &: (Symbol#to_proc) and returning methods in there somehow. ...

How do I create a button that enters a string into a form using Ruby on Rails?

Hello I am a Rails Noob so I apologize if this is elementary. I'm creating a Twitter-like application and working on a 'reply' button that will automatically place a variable (the username of the tweet's author) into the tweet form at the top of the page. This is what I have now: def reply @tweet = Tweet.find(params[:id]) @messa...

Getting the skype status of user in a rails application

I have a rails application in which user provides his skype address.I want to able to determine the skype status of the user(online or offline) when some one sees his profile. How can i do that in my application? Does any know of a ready to use gem/plugin? ...

Simple custom range in Ruby

I have a Rails named_scope which is using a condition to pull specific days of the week from the table like so: :conditions => [ 'EXTRACT(DOW FROM bookdate) IN (?)', (1..6).to_a ] The 1..6 date range will be a variable depending on the dates the user wants, Which produces this SQL (EXTRACT(DOW FROM bookdate) IN (1,2,3,4,5,6) My pr...

Is Ruby 1.9.1 actually ready and faster for a new Rails deployment?

I'm not going to make this into a Rails vs Framework X discussion, there's plenty of those already. After seriously contemplating what framework I'm going to use for my next deployment, I decided it's very difficult to pass up the out of the box REST exposure Rails gives you for minimal work back. This is something that requires slightly...

Running more than Rails apps on a local Mac

I would like to set up multiple Rails apps running simultaneously. I'm using a basic installation with Rails and Mongrel. I'm pretty newbie when it comes to a server side thing. What kind of options do I have to run multiple Rails app running at the same time on a local Mac? ...

How do I make dynamic ids in Haml?

#item creates a div with id="item" .box#item creates a div with class="box" and id="item" .box#="item "+x creates a div with class="box" and a comment '#="item"+x' .box# ="item"+x throws "Illegal element: classes and ids must have values." How do I get set the id to a variable? ...

Ruby on Rails Nesting Blocks

Hi I have a block that I need to nest another block in. Or maybe I don't and I am doing this totally wrong. There is a UNIT and the UNIT has_many COMPANIES Then COMPANIES has_many USERS on the UNIT show page I am trying to do something like this: <% @company.each do |c|%> <%= c.name %> <% ??? each do |f| %> <p> Name: <%= f....

Ruby on Rails - Checkbox not saving to database?

I've got a migration which uses a boolean value and generates a checkbox in its view. However, no matter what I click, the value saved to the database is not affected. My migration looks like this: def self.up create_table :blogposts do |t| t.string :title t.text :body t.boolean :allow_comments, :default => false...

How to re-route the GET resource to return the EDIT view in Rails

My question is fairly simple, in an app I'm building, there is no need to show a user's account as a separate action from editing a user's account. That is, instead of URL | HTTP Verb | Action ============================================ /account/new | GET | new /account/edit | GET | edit /account | ...

How can we Override ActionController in rails to common out certain methods?

I have the authentication code to be available over several Controllers. So I thought of putting the Authentication code in to a SuperClass and then make all the other controllers extend this SuperClass. I then got to know that we can add it in the ActionController class itself. How can we do that? Is there a way to change the pre defin...

undefined method `form_for' for module `ActionView::Helpers::FormHelper'

Argh! Everything has been totally fine, then all of a sudden I started getting this error when I was doing a 'rake db:migrate' And I get the same thing when I try to restart the rails server. rake aborted! undefined method 'form_for' for module `ActionView::Helpers::FormHelper' Confirmation that I'm running a current version: mm-MacBo...

undefined local variable or method

Ok this worked: Student.transaction do if @student.test! y = @student.rooms.first book = Book.find(:first, :conditions => ["room_id = ?", y]) It's strange. I wanted to get the last record not first, yet it thought first was the last and worked. Not sure why. ...