ruby-on-rails3

Rails route which disappears in application but is present in rake routes...

Hello, I have a mystic problem.... In my routes.rb I have some routes defined and for exemple resources :projects, :except => [:destroy] do get :edit_flyer, :on => :member get :guests, :on => :member end If I run a rake routes, I get edit_flyer_project GET /projects/:id/edit_flyer(.:format) ...

Rails 3 add GET action to RESTful controller

I have a controller with the 7 RESTful actions plus an additional 'current' action, which returns the first active foo record: class FooController < ApplicationController def current @user = User.find(params[:user_id]) @foo = @user.foos.where(:active => true).first #use the Show View respond_to do |format| for...

How to reload all gems in Rails 3?

Is there some way to reload all gems in a Rails app without completely restarting the server? I've got a Gemfile that uses :path to reference a dependency that I'm developing on the same system, and it's annoying to have to kill the app and do rails -s again every time I save a change. It'd also be nice in production to be able to update...

How can I colorize logger output in a rails 3 console

How can I colorize and possibly bold the output from Rails.logger in my rails3 application? ...

Remote form with A tag submit in Rails 3

Hi guys! I have a remote form with hand-made buttons using tags. I'm using data-remote=true in the form tag, but I don't know how to use the link tag to post the form data in a form submit. When I use data-remote with data-method, it creates a remote call with empty parameters, so I doesn't call the submit() function to my form. My fo...

Render file Rails3

I'm trying to render a png file in a controller in Rails3. I'm using: render :file=>'public/images/filename.png' However, the output seems not to be a PNG file (its contents start with "PNG" -checked it with curl- but it's not a valid file). I cannot find documentation on render :file in Rails3. Has the syntax changed for this? Even i...

rails3 controller generator generate wrong routes

Hi, I am giving a show to rails3 rc. rails g controller sandbox/test1 index It creates the following line in routes.rb get "test1/index" It should be: namespace :sandbox do get "test1/index" end Am I misunderstanding or is it a bug? Thanks. Sam ...

Best way to add page specific javascript in a Rails 3 app?

Rails 3 has some unobtrusive javascript which is pretty cool. But I was wondering what the best way is to include additional JS for a particular page. For example, where I might have previously done: <%= f.radio_button :rating, 'positive', :onclick => "$('some_div).show();" %> We can now make it unobtrusive with something like <%= ...

Getting user_id in model

I'm Rails newbie so this might be incredibly stupid question but I hope somebody finds the time to help me :) I'm currently doing my first Rails 3 application with MongoDB. I have setup Devise for authentication and it's working great. I'm trying to create blog type of app so each registered user can post an article. Naturally user mode...

Overriding public-directory in Rails 3?

I'm building a template system for a CMS in Rails 3, with each template placed in {application_root}/templates/{template_name}/. For each template I would like to have a public-directory that overrides the standard one. How can it be done? ...

Rails: multiple names for a resource

Is there an elegant way of having multiple names for a single resource. We would like to give the user a choice via a setting of what they would like to call their "things". I.e. products, items, services whatever. So far I can only think of using multiple routes to a single controller: resources :products resources :items, :controller...

Restrict access to some model items in Rails 3

I have Post model with published? field and some authorization system which defines admin? method inside ApplicationController. I want to restrict access to unpublished posts and show them only to administrator. I tried to define a scope accessible to return only published posts to users, but all posts for administrator. scope :publis...

Rails3: Serve a file statically that is not in "public/"

How do I serve a file statically with the correct content-type headers if it is not (for good reason) in the "public/" directory? ...

Difficulty in testing a CSV upload, due to Rails thinking it should use it to populate test data.

I have a case where I want to test a file upload but I'm having problems breaking a circle of pain. We are checking that the file uploaded is a CSV file, so the file should have the extention .csv. To test we need to use ActionDispatch::TestProcess.fixture_file_upload and we place the test file in the test/fixtures/files diectory. Now ...

Can you remove the _snowman in Rails 3?

I'm building an app on Rails 3 RC. I understand the point behind the _snowman param (http://railssnowman.info/)...however, I have a search form which makes a GET request to the index. Therefore, submitting the form is creating the following query string: ?_snowman=☃&search=Box I don't know that supporting UTF encoding is as important...

declarative authorization filter_access_to

I am attempting to secure a Rails3 controller using declarative_authorization. The controller has the 7, RESTful actions, three custom member actions (activate, deactivate, copy), and one custom collection action (public). The 'public' action only returns one record, however. Only the custom collection action (public) should be availa...

raise I18n exceptions from within cucumber tests (rails 3)

I'am currently trying to get i18n into our rails application. I use cucumber for integration testing and test_unit for everything else. After the initial translation and "refactoring" the locale file, I have a few missing translations in my app, due to changed translation keys. What I want now, is that cucumber reports all missing tran...

UsersController in Admin namespace seen as the one defining UsersController?

In rails console I get the following: >> UsersController LoadError: Expected /../app/controllers/admin/users_controller.rb to define UsersController I'm using Rails 3.0.0.rc. Exact same code works fine for 3.0.0.beta3 and 3.0.0.beta4 BTW. In short the controllers look like: app/controllers/admin/users_controller....

Configure Memcached with Rails 3

Hi :) I'm having problems trying to use Memcached in a Rails 3 Application ... My question is quite simple : How I'm supposed to configure Memcached to make it works with Rails 3 ? Thanks for your help ! Edit: It looks like the object isn't correctly deserialized by the Rails.cache.read no matter :raw => true or :raw => false but th...

Rails 3 multiple accounts authentication solution

I am searching for a working solution of authentication on Rails 3 with the following features: account types: standard login, facebook connect, openid, oauth one user may have (and link) multiple accounts (EG a user attach both Wordpress and Google OpenID accounts) A working example of Rails app implementing them would be perfect. ...