ruby-on-rails

Rails 3 Routing Error - "No Route Matches"

I'm following along with the O'Reilly Rails book, but it's created for Rails 2, so I think that's where the error lies. In app/views/entries/sign_in.html.erb: <html> <head><title>Hello <%=h @name %> </title> </head> <body> <h1> Hello <%=h @name %></h1> <%= form_tag :action => 'sign_in' do %> <p>Enter your name: <%= text_field_ta...

Recommendations for good 'paging' and 'tagging' plugins/gems in Rails 3?

I am building an app that will have galleries of thumbnail images to browse through. Potentially thousands or more. I am looking for recommendations on any existing plugins or gems for paging through large result sets and, for example, showing 50 thumbnails on a page with a link to show the next 50 and so on. Second, I want to organize ...

paperclip - Saving the images Dimentions? width,height

Hello? Any paper_clip wizards out there know if you can when using paperclip to save an image, also save the image dimensions (width&height) in 2 extra fields? How do you get such data during the paperclip upload process? Thank you ...

in rails, What is the value returned in for a checkbox?

I want to set a cookie to expire in 1 year if the 'remember me' checkbox is checked. I have a checkbox form input like: <%= check_box_tag 'remember', '', false, :class => 'checkbox' %> what will the value be when it gets posted? will it be true/false or checked or 1 or? I set the value to '' in the helper. ...

Ruby / Rails - .each Iterator is printing entire array at the end of the loop.

I think what I'm trying to do is pretty simple, and I'm really not sure why this isn't working. I'm using Rails 3. Essentially, I'm just trying to select the distinct values from a column in an existing model, and print them out all. For the most part, this works but the .each loop in my view also ends up printing the entire array at t...

Rails - AJAX a Modal Dialog?

Hello, I'm interested in learning how to AJAX a modal dialog. Typically if I wanted to add a modal dialog to my web site I added the jquery UI dialog code in my main JS file and binded it to an ID. I believe with Rails I can create a Link, which fetches all the dialog code from the server and then opens the dialog. Is this true? If so...

should I be using 1.9.2 or 1.8.7 for rails 3.0 production apps?

I'm currently using 1.9.2 with rails 3, and I ran into a snag with ruby-debug. Should I be using 1.8.7 to be more on the safe side with rails 3? I'm new to rails, and I want to stay away from hackish workarounds or configuration nightmares. (I'm using rvm) ...

Rails MySQL include restrictions

Hi, I have these models: class Comment < ActiveRecord::Base belongs_to :post belongs_to :user end class Post < ActiveRecord::Base has_many :comments belongs_to :user end class User < ActiveRecord::Base has_many :posts has_many :comments end I'm trying to pull out Post data, while eager loading the User and Comment da...

Calling a controller's action without a named route in Rails 3

In Rails 3, is there a way to link to a controller's action using ajax without having a named route? I tried <%= link_to 'Reload', '#', url_for(:action => :reload, :id => @user.id), :remote => true, :method => 'post' %> but it returns with the error No route matches {:controller=>"users", :id=>2, :action=>"reload"} My main concern is...

Rails relationship's advice.

I need to model the following relationships and would like some advice on how to properly model it. There is a user, house, apartment, garden, furniture So a user can either have a house or an apartment but not both. Both house and apartment can have furniture but only the house can have garden. So the biggest issue is user has_one ...

rails to_json not following scropes

When I just the to_json method it seems to ignore all other options... any ideas how to fix this? var places = <%=raw @location_for_map.limit(5).to_json(:only => [:name, :lat, :lng]) %>; I'm trying to plug in points from json on a google map, but noticed the points never got smaller with any of my scopes. where, order, limit... I cou...

Shortcomings of modelling roles as boolean columns on User table

I'm working on a Rails app using CanCan for RBAC and I only have 3 roles and maybe I'll add 1 or 2 more somewhere down the track. In the past I've always had roles as their own entity, joined to users via a m2m link-table. With so few, and static, roles, that seems like overkill. So I'm thinking of simply adding boolean columns to my ...

How do I trace which file RSpec is loading?

I'm using Rails 3.0.1, RSpec-Rails 2.0.1 and Webrat 0.7.1. I have the following test: describe PagesController do describe "GET 'main'" do it "should have the right title" do get 'main' response.should have_selector("title", :content => "My title") end end end The HTML of pages#main checks out: it contains My ...