ruby-on-rails3

Limiting the number of thumbnails on facebook share

So I want users to be able to share this link on facebook but I want only a specific picture to be the thumbnail for this sharing picture and no other images that appear on my web site I read the documentation about facebook share and I got this http://developers.facebook.com/docs/share Basically what I understand is that <link rel=...

How do I handle a VirtualHost/Passenger entry for a Rails site that solely handles subdomains?

I want to use Rails 3's new subdomain features to handle all subdomain paths except www and nil. Oppositely in a second rails app, I want to solely handle www and nil in the url path. What would my two VirtualHost entries look like for Apache with Passenger? And in the code, for the first subdomain handling app, so long as I handle th...

How can I send emails in Rails 3 using the recipient's locale?

How can I send mails in a mailer using the recipient's locale. I have the preferred locale for each user in the database. Notice this is different from the current locale (I18n.locale), as long as the current user doesn't have to be the recipient. So the difficult thing is to use the mailer in a different locale without changing I18n.loc...

Rails 3 server encountered an internal error or misconfiguration

I have just setup a Rails application on Bluehost. Everything appeared to have gone smoothly, however, when I visit the home page and click on the 'About your application’s environmet' link I get the below error. I followed the following tutorials: Bluehost: helpdesk.bluehost.com/index.php/kb/article/000207 RailsGuides: edgeguides.ru...

In Rails 3, how can I skip validation of the password field when I'm not attempting to update the password?

My User model contains :name, :email, and :password fields. All 3 have validations for length. An "update account" web page allows the user to update his name and email address, but not password. When submitted, params[:user] is {"name"=>"Joe User", "email"=>"[email protected]"} Note there is no "password" key because the form doesn...

Rails way to render different actions & views based on user type?

I have a couple different user types (buyers, sellers, admins). I'd like them all to have the same account_path URL, but to use a different action and view. I'm trying something like this... class AccountsController < ApplicationController before_filter :render_by_user, :only => [:show] def show # see *_show below end def...

Help convert a nested route to Rails 3

I have a comment form (in comments/_form.html.erb) that I use in my other controllers (posts and tags). <% form_for([@post, Comment.new], :html => { :multipart => true }) do |f| %> <%= f.text_field :commenter %> <%= f.text_field :email %> <%= f.text_area :body %> <%= f.submit 'submit' %> <% end %> In my Comment mo...

Undefined webrat methods in cucumber step_definitions

Hi there, When i run my features i get this error: undefined method `visit' for #<Cucumber::Rails::World:0x81b17ac0> (NoMethodError) This is the relevant part of my Gemfile. group :development, :test do gem "rspec-rails", ">= 2.0.0.beta.19" gem "cucumber" gem "cucumber-rails", ">= 0.3.2" gem 'webrat', ">= 0.7.2.beta.1" end ...

Rails3: combine scope with OR

Hi, I need to combine name scope with or operator... Something like: class Product < ActiveRecord::Base belongs_to :client scope :name_a, where("products.name = 'a'") scope :client_b, joins(:client).where("clients.name = 'b'") scope :name_a_or_b, name_a.or(client_b) end Thx ...

Deprecation warnings on Rails 3 RC don't help me

Very often in Rails 3, when I get a deprecation warning, the line reference I get is in the Rails framework instead of the actual deprecated line! For example, I try to save a user model : irb(main):006:0> user.save DEPRECATION WARNING: save(true) is deprecated, please give save(:validate => true) instead. (called from save at /home/...

Controller helper_method

I was wondering why someone should use helper_method inside a controller to create a helper method, instead of creating the "normal" way, which is inside the helper file. What the pros and cons of that? ...

No details for authentication in Authlogic & Facebook Connect

After following the guide to add Facebook Connect to an Authlogic-enabled Rails app (see http://github.com/kalasjocke/authlogic_facebook_connect), I get the following error when I click on the Facebook's "Connect" button: You did not provide any details for authentication. It seems that UserSession.create(params[:user_session]) is tryi...

Uninitialized Tag constant in Rails 3 with Acts_As_Taggable_On

This controller action worked perfectly in Rails 2.3.x: def show @title = Tag.find(params[:id]).name @tag = Tag.find(params[:id]) @messages = Post.paginate(Post.find_tagged_with(@tag), :page => params[:page], :per_page => 10, :order => "updated_at DESC") @related_tags = @related_entries.collect{|x|x.tags}.flatten....

Rails 3 Cucumber Load Error

I am trying to get cucumber to work with Rails 3. But whenever I try to run the cucumber features I get an load error. cucumber-0.7.3/lib/cucumber/ast/feature_element.rb:2:in `require': no such file to load -- gherkin/parser/tag_expression (LoadError) I have added the following gems to the Gemfile gem "rspec", '>= 2.0.0.beta.19' gem ...

Rails 3 application settings

I need to keep application's settings editable by admin users through web form. I've found rails-settings gem to keep hash of simple string settings. But app settings need to keep not only string parameter but lists of another models (e.g. PaymentPeriods with name:string, etc). My question is: how to organize such app settings in the r...

Using helpers in rails 3 to output html

Guys, I'm trying my best to build a helper that outputs a <'ul> consisting of all the members of a collection. For each member of the collection I want to print out a <'li> that has a title, and a div of links to CRUD the member. This is pretty similar to what Rails outputs for scaffolding for the index view. Here is the helper I've ...

Rails activerecord: query for record by a datetime field?

I'm trying to query for records in the TimeSlot table by the field start_date which has type datetime. Here's what I've tried so far that's failed: TimeSlot.where(:start_date => DateTime.new(2010, 9, 1)) TimeSlot.where(:start_date => DateTime.new(2010, 9, 1).to_s) TimeSlot.where(:start_date => "2010-09-08") TimeSlot.where(:start_date...

.collect on a belongs_to raising NoMethodError: undefined method `add' for nil:NilClass

Setup: Rails 3 RC2, Ruby 1.9.2 p0 (also tried on Rails 3 beta 4, Ruby 1.8.7 p174) I have quite a basic shopping cart setup: Order has_many :order_items Order has_many :products, :through => :order_items, :dependent => :restrict Product has_many :order_items Product has_many :orders, :through => :order_items, :dependent => :restrict O...

Writing view_spec for login form with authlogic (rspec2)

Hi there, i am trying to write a view_spec for my login form that uses authlogic. This is my current view_spec: require 'spec_helper' describe "user_sessions/new.html.haml" do before :each do user_session = mock("UserSession").as_null_object assign(:user_session, user_session) end it "should have a login form" do re...

Rails 3 reset session using devise

Hello, I am developing a Rails3 application and Devise for authentication. In the course of the workflow, I am storing information in the session, like patient_id. But, when the user log's out, I need to clear the session. I could've done it if I has control of user login and logout. But, now devise handles it. How could I do it? ...