ruby-on-rails3

Active record query with includes does not include...

I have got this 'query' @product_collections = ProductCollection. #includes(:products). #does not do anything joins(:products). #this at least gives me the products (in articles table) group("tags.id"). where("articles.category_id = ?", @category.id). where("articles.available = ?", true). ...

/session instead of /login when login attempt failed

sessions_controller.rb def create if user = User.authenticate(params[:login], params[:password]) session[:user_id] = user.id redirect_to posts_path else render :action => 'new' end end routes.rb get "sessions/create" get "sessions/destroy" get "sessions/new" resources :posts resource :ses...

How can I create previous version rails in rails 3?

I've just upgraded my rails version to rails 3.0. But suddenly I need a new rails app with old version of rails. I know the new version of rails change command line usage with 'rails new'. How can I create an old version of rails in this new rails 3 environment?? ...

Rails 3 :method=> :delete doesn't work in Internet Explorer

I am going through the rails 3 tutorial at railstutorial.org. I have just created an extremely simple scaffold Users. The scaffold-generated destroy link does not work in Internet Explorer. It redirects to the show action instead of deleting the user. This problem only happens in IE9 and IE8 (the only IE versions I've tested so far) Th...

Why doesn't this view display posts in descending order? (simple question)

home_controller.rb: class HomeController < ApplicationController def index @title = "tags" @posts = Post.tag_counts.collect do |tag| Post.tagged_with(tag).first end @posts.flatten.uniq @posts = @posts.paginate :page => params[:page], :per_page => 8 end end index.html.erb: <%- for post in @posts -%> ...

Selenium can't launch firefox without sudo in Rails cucumber testing

I have a weird bug when trying to run selenium with cucumber testing in Rails 3. (This is under an RVM running 1.8.7) My colleague's dev environment works just fine but when I try and run "AUTOFEATURE=true autotest" or "rake features" I get the following error: unable to start Firefox cleanly, args: [] (Selenium::WebDriver::Error::WebD...

Ruby on Rails 3 Submit Form with a button

Submiting a form <%= submit_tag %> Is there anyway to submit aform using a button instead of the submit_tag? Nor do I want to use the image_submit_tag. What other options do I have to submit a form? I understand that the submit_tag produces <input type="submit">. Thanks in advance. Edit: I'm interested in reusing some of my css....

No method error in rails 3 app

I'm getting this error: undefined method `post_comments_path' for #<#<Class:0x1052a6e98>:0x1052a4be8> Extracted source (around line #27): 24: 25: <% end%> 26: 27: <% form_for [@post, Comment.new] do |f| %> 28: <p> 29: 30: <%= f.label :name, "Author" %><br /> My routes: Myblog::Application.routes.draw do root :to => ...

Delete link sends "Get" instead of "Delete" in Rails 3 view.

I'm using Rails 3 and have have a page that outputs a list of posts from the database. I'd like to be able to delete a post from a link. The 2nd example below works, but the first doesn't. Anybody know why the first won't work? My view contains: # this link sends a "GET" request which asks for the #show function <%= link_to 'Delete',...

create.js.erb, destroy.js.erb: How do these files fit in a Rails app

I haven't been able to find documentation that talk about how create.js.erb and destroy.js.erb fit in a Rails 3 app. What is the logic behind these types of Javascript files in the app > controllers? How and when are they accessed? ...

Ruby on Rails 3: link_to create new nested resource?

I am trying to make a link to create a new nested resource in my Rails 3 application, but I can't figure it out. What is the syntax to link to a new nested resource Solution: Make sure you have your resources properly nested in your routes file. resources :books do resources :chapters end Then in your view script you can call it l...

Ruby Rack issue

I am newbie to Ruby on Rails This is what happened I got a hosting from bluehost which supports RoR. I download a Rack-based open-source web font server. I copied that to my hosting domain. I tried to startup that server using rackup filename.ru, but rackup is not avaliable... what 2 do now How to start this server. ...

Can Ruby on Rails 3 work with MySQL on Windows 7?

I try to install Rails 3 on Windows 7, and rails new someapp -d mysql cd someapp bundle install will fail at mysql2 so, there is no way to use MySQL but to stick with SQLite3. But I tried rails new app_postgres -d postgresql cd app_postgres bundle install and it all worked. Does that mean perhaps Rails team favor Postgresql slig...

is there any hack to get around jruby( on rails)'s being so slow to start?

Possible Duplicate: How to improve jRuby load time? When developing a site using jruby on rails I find it quite annoying that every time I invoke jrake db:migrate or rails g migration I have to wait a few seconds for the java engine to start... $ time rails -v Rails 3.0.0 real 0m6.947s user 0m10.590s sys 0m0.230s ...

Model version control in Rails

I am new to Rails / Ruby. I am working on a project where we want to capture snapshots/revisions of the objects when certain operations happen. Its similar to the how the revision control works for the Writeboards in basecamp. Is there any gem which will automate this functionality or some open source project in RoR which we can use as a...

Are default routes broken with Rails 3 engines?

I have a Rails 3 engine gem that is for basic user authentication and authorization. Within that Gem the config/routes.rb defines the following resources :users match '/:controller(/:action(/:id))' When I do a rake routes from the application that requires this gem I get the following routes rake routes|grep users users GET /users(...

Automatic SASS to CSS in RoR 3 without sass --watch

Hi 2 all, I've read all topics re. SASS + RoR, but there are no answers for my small question. I'm running Rails 3 and using alternate syntax, without SCSS. Haml gem included in the project. What else should I configure to have autogenerated css files without "sass --watch"? Thanks in advance! ...

jquery datepicker not working properly with js.erb views in ruby on rails

Hi i have two js.erb views, namely new.js.erb and edit.js.erb with both use a form partial to be rendered in a dialog box. Two of the fields in the form are start date and end date to which i have added the datepicker from jquery ui as shown below $("#event_startDate").datepicker({dateFormat: 'yy-mm-dd'}); $("#event_endDate").datepicker(...

Migrating from Rails 2 to Rails 3

What resources are out there (free or paid) that help walk you through the process of migrating a Ruby on Rails 2 application to Rails 3? I've seen some blog posts (some of which seem out of date) and an eBook for sale somewhere on the RoR website, but what can you recommend as an accurate and complete explanation of what changed from ve...

Rails 3 & jQuery - How the two work together to create a web app?

I need helping understanding the end to end flow in Rails. I could use help with the following example.. Lets take Facebook. When you're on Facebook.com, and click MESSAGES, the URL changes to (facebook.com/?sk=messages) and then AJAX is used to download the HTML/ JS content which is injected with JavaScript into the content pannel.....