ruby-on-rails

Difference between t(:str) and t :str in ROR

Hi , i am new to ROR.. i am having a doubt in internationalization commands. in some case we were using <%=t :str_use%> and in some cases we were using <%= t(:str_use) %> what is the difference between these two when should i have to use 1st and when to use the second one.. Pls give some ideas regarding this. i am having a vi...

How to follow redirect from javascript in cucumber?

I have a a button (not a submit button) which does ajax calls before submitting another form. What I want to do is Given I am viewing homepage When I press "JustAButton" Then I should be on "/users/home" But the redirection happens somewhat late and "Then" statement fails considering that the page is still in homepage. How can I wait...

lockfile_parser.r :48:in `parse_source': undefined method `[]' for nil:NilClass (NoMethodError)

I've been messing around with both RubyOnRails3 and Git for the first time. Everything had been going along smoothly until all of a sudden any rails related command line argument stopped working. Unfortunately I have no idea what caused this or how to go about fixing it. Here's the output from the command line C:\railstest\railsproject...

Strange DoubleRenderError in Rails 3

I'm trying the standard redirect_to some_path and return syntax but for some reason Rails 3 isn't liking this. class MyController < ApplicationController def some_action redirect_to "http://www.google.com" return end end Gives me the standard error message: Render and/or redirect were called multiple times in this action....

Reuse js.rjs files in Rails ?

Hi, i have an .js.rjs file, that must be used in many places. How can i reuse it ? For example, in my .js.rjs file i need something like this: page << ( render "widely_used_stuff" ) where "widely_used_stuff" is a widely_used_stuff.js.rjs file, that contains the code, used in many places. Also, i need to pass the variables to widel...

params used in the link in Rails

Hi , I am having a doubt in ROR. I am having a code .I am trying to study the code given .There i m having a api folder with in tat i am having a files .. In one of the file There is a index action of the controller file there are params like params[:limit] and params[:sort].. I wanna to check of how the link works frm api .. i tried...

Ruby on rails Authlogic gem and Password_Reset without ending in Edit

I followed this password_reset tutorial and was able to get it working. But there are a few things I don't like about it that I want to change. I'd like it to say password_reset rather than reset_passwords in the url. Which I've managed to accomplish by renaming the controller and routing it in config/routes.rb as map.resources :reset_...

Use HTML inside a Rails translation file

I have some translations in my Rails application (config/locale/[en|de].yml) and I use it in my views with <%=t "teasers.welcome" %>. Example: teasers: welcome: "<strong>Welcome</strong> to the Website ..." In Rails 2.3.8 this works just fine, with Rails 3, the HTML is escaped and translated to &lt;... How can I prevent this form ...

Using Struct with Rails

Hi, I came across this messaging tutorial recently, and was intrigued by the use of Struct.new. With a bit of help from google and SO I've learnt a bit more about the use of Struct in Ruby, but I would like to know a bit more about its use in Rails. In the tutorial, there is a folder model which stores the user's recieved messages: cla...

Why I got an error if I named my controller as "leaves" in Ruby on Rails

The scaffold command is the following ruby script\generate scaffold Leave employee_id:integer leave_type_id:integer date:date I know I could change the name but I just wonder why it always throws undifined new_leave_path Glad to know your brilliant thoughts. Below is the full details of the error: NameError in Leaves#index Show...

Problem installing gem pauldix-feedzirra on windows

I am trying to install pauldix-feedzirra gem on windows xp and getting error like this : Building native extensions. This could take a while... ERROR: Error installing pauldix-feedzirra: ERROR: Failed to build gem native extension. C:/InstantRails-2.0-win/ruby/bin/ruby.exe extconf.rb checking for curl-config... no checking f...

rails 404 error in subfolders in public

Hi, it looks for me that crawlers try to resolve the index of all public folder subfolders like "/images/foo", which makes a 404 error. Should I do something or is this normal? ...

Rails3 RSpec is wiping wrong database?

I am trying to get my hands on Rspec2 with Rails3 (never used rspec before). I have rspec-rails 2.0.0.beta20. After introducing some basic tests into spec/models and running rspec spec/models/user_spec.rb everthing is fine. However if I just run rake spec My development database is beeing wiped out. Even if I specify the environme...

How to test for in class body method calls?

class Category < ActiveRecord::Base acts_as_tree end How to test that acts_as_tree gets called? Or that any other in class body method gets called? ...

Anyone know why I'm getting this RSpec error? getting nil <--

def mock_category(stubs={}) @mock_category ||= mock_model(Category, stubs).as_null_object end describe "GET show" do it "assigns the requested category as @category" do Category.stub(:find).with("37") { mock_category } get :show, :id => "37" assigns(:category).should be(mock_category) end end Which returns : 1) Cate...

Any Rails plugin to add comments about each column in ActiveRecord migration files?

I'd like to insert COMMENT, which is part of SQL the command, in my migration files. As far as I know, I can add COMMENT to each table and column. I can't remember a plugin name that lets me to write as follows: t.string :name, :comment => "A user's fullname" t.string :label, :comment => "name of color" t.text :value, ...

The most common shortcut in Textmate doesn't work?

The shortcut for jumping to the beginning or end of a line of code with ⌘ + -> or ⌘ + <- does not work. I just get a mac os x system beep. I believe this shortcut is universal to the mac os x platform, and not specifically TextMate, and it and it does work everywhere else (TextEdit, StackoverFlow, etc.). Why would TextMate conflict wi...

Rails console with special initial commands

I'm using Rails script/console to learn REST routes. It is very handful! In order to do that I need to paste these two lines every time I run console: include ActionController::UrlWriter default_url_options[:host] = 'whatever' If there is any way to make a script which will add this automatically every time I run console? ...

rake task on gem

I have a rake task for a series of rspecs as follows... require 'spec/rake/spectask' require 'joliscrapper' namespace :spec do desc "Web scraping files" task :scrapers => :environment do Spec::Rake::SpecTask.new do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['spec/scr...

Which rails server for development?

Is there a "best" rails server to use for development (mongral, webrick, etc..)? Or does it not really matter? ...