ruby-on-rails3

How to set ActiveModel::Base.include_root_in_json to false?

I'm using Rails 3 w/ Mongoid, (so no ActiveRecord). Mongoid uses ActiveModel's "to_json" method, and by default that method includes the root object in the JSON (which I don't want). I've tried putting this in an initializer: ActiveModel::Base.include_root_in_json = false But get the error uninitialized constant ActiveModel::Base ...

Rails 3 - Ideal way to set title of pages

Whats the proper way to set the page title in rails 3. Currently I'm doing the following: app/views/layouts/application.html .... <%= render_title %> <%= csrf_meta_tag %> .... app/helpers/application_helper.rb ... def render_title return @title if defined?(@title) "Generic Page Title" end ... app/controllers/some_controller.r...

Rails 3 routes and modules

I have a AR model inside a module class Long::Module::Path::Model < ActiveRecord::Base end and want to use following routes (without the module names, because it's easier to write and remember) resources :models buts Rails 3 always wants to use a URL like long_module_path_model_url Is there are way to change this behavior? Hope...

Initialize a Rails 3 plugin gem on installation

I'm creating a RubyGem, and I'm wondering if there's any way I can set it up so that when it's listed in a Gemfile and someone runs bundle install, my gem can copy some files into the Rails path. This would save the user from having to type rails generate blah, where blah is the name of a generator in my gem. Is there a callback that th...

Facebook Graph API with Rails and Authlogic - preferred methodology?

There are lots of Facebook + Rails solutions, most notably Facebooker, but this and many others are not compatible with Rails 3. I'm currently using Authlogic for authentication with my app, and I want to give users the option of Facebook to sign in. I want to find the best way to have FB and Authlogic go together; right now I'm just wri...

render partial using ujs and without AJAX call on rails 3

I need to do multiple file uploads using nested form and jQuery. so I wrote an helper using link_to_function method: def add_document_link(title, form) link_to_function title do |page| form.fields_for :documents, Document.new, :child_index => Time.now.to_i do |f| page << "$('#documents').append('#{escape_javascript(r...

Rails 3 jquery in js.erb template is creating escaped html?

In Rails 3, I've got an update.js.erb template with one simple line of jquery: $("#some_div").html("<strong>some_content</strong>"); Upon form submission, all the ajaxy stuff is working fine, but the content in #some_div is being replaced with "<strong>some_content</strong>" instead of some_content. Does anyone have a clue why? This ...

Devise DoubleRenderError

Application-Stack: Rails3, CanCan, Devise, Shoulda I've got some nested Resources and want to test them with Shoulda and i get the following DoubleRenderError: Error: test: If anonymous user tries to GET index of fav_blogs should respond with 401. (BlogItemsControllerTest): AbstractController::DoubleRenderError: Render and/or redire...

will_paginate produces escaped html in rails3, raw and .html_safe do not seem to help.

will_paginate produces escaped html, what am I missing here. I've verified that will_paginate producted html_save code, I've tried adding will_paginate(@pictures).html_safe as well. Note that page_entries_info works as it should, its just the main helper that is messed up. For the time being I've done the code manually, but for obviou...

rails 3 - app design question - models and controllers

Hello, I am building small app that will only display products in various categories. And will never display categories without products. So far I have two models - product and category and wondering if I really need controller dedicated to category model? I can only see one advantage so far - rendering collection (partial) of category. ...

A/B framework for Rails 3?

Is there anything like ABingo or Vanity that works in Rails 3? I know there's Google Website Optimizer, and Visual Website optimizer, but I need more power w/ regard to determining what is displayed, and what is in turn tracked than they can provide. If not, I'll even take thoughts on frameworks that are relatively simple enough that I...

Creating a Ruby on Rails 3 gem with a generator (incl. namespace)

I am trying to create a gem with a generator for Rails 3 (beta 4). I followed these instructions, and but I couldn't get it running. The problem is that when I am defining a module in the generator file, the generator gets listed with 'rails generate', but can't get executed because the generator isn't found. From the instructions (does...

Using lightbox_me for forms in rails 3

Hello I would like to use the jquery lightbox : lightbox_me in order to manager my new and edit forms. My forms are working in simple AJAX, but I don't know how to do to include them into the lightbox and make it works? Any advise? Thanks in advance. Fabien ...

How can I make my 'sunspot-solr start' work ?

Hi guys, I'm have problem to start my sunspot-solr. I'm fallowing instructions from this github/wiki So I made the installation part without trouble apparently. End then I tried to start it with: sunspot-solr start -p 8982 -d solr/data/development -s solr --pid-dir=tmp/pids -l FINE --log-file=log/sunspot-solr-development.log It didn...

Rails 3: app template example?

I'd like to see an example of an application generator template for Rails 3. Any suggestions? I'm interested in an example of a template that is used to generate a new Rails application. Ryan Bates has a screencast (#148 App Templates in Rails 2.3) that describes how to create an application generator template for Rails 2.3 but I'd like...

Problem with nested associations in Rails3

Hi guys, I'm having a problem with some associations in Rails3. I have the following associations InformationCategory :has_many => Informations :has_many => InformationValues I'm able to succesfully do the following: Information.first.information_values => [#InformationValue..] I'm also able to do the following: InformationCateg...

Heroku and Rails 3 - Routing that works locally breaks in cloud

Using Rails 3 Beta 4: I'm getting this error, but can't quite follow why, as it's working locally. It's a pretty small application at the moment, and I can see that one controller is working, but the SessionsController is not. Does this uninitialized constant error look familiar to anyone? Started GET "/sessions/create?code=2.pzgz...

In Rails/ActiveRecord 3, how do I change the default primary key type for MySQL?

In Rails 3, how do you change the default primary key type to, say, BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY In my case I'm only interested in MySQL. For Rails 2, you can see the answer to "How do I use long IDs in Rails?"1 In Rails 3, however, this will throw an error. I'm not sure if that's because the class is no long u...

Rails ignores collection route and goes with show action instead

I have the following routes set up in my routes.rb file: resources :people do collection do get :search end end When i do a get action on the url: http://localhost:3000/people/search.json?term=stepeb, the server reports that it's responding with the show action, with the correct term parameter, but also has an id parameter, s...

Using a rails partial in a jquery dialog box

Hello, I'm trying to insert a partial into a jquery dialog box. The dialog box is working but no partial.. Here is my code : application.js $(document).ready(function(){ $("#add_note").click(function(){ $("#notes").html("<%= escape_javascript(render(:partial => @note)) %>").dialog({title: 'Basic Dialog'}) }) }) my vi...