ruby-on-rails

Rails - Devise - How to Handle Landing Pages Versus App Pages

I have a Rails 3 App. When the user is not signed in... I want devise to show non-signed in pages: SignIn, register, about us, blog etc... When a user is signed in I want it to go to the web app where do I make this switch and how do I set it up? thanks ...

Additional formatting on a <pre> tag

I am using <pre> tags to preserve long strings of text that include user-entered line breaks. When the input into the original form was exactly: Paragraph 1 Paragraph 2 Paragraph 3 ...the pre returns: Paragraph 1 Paragraph 2 Paragraph 3 In the database, the string is stored: "Paragraph ...

Failure adding a hash literal to an array in Ruby on Rails

Within a controller, I have this code: @placements = [] empty_placement = { 'placement' => { 'competition_id' => '', 'division_id' => '', 'dancetype_id' => '', 'leader_id' => '', 'leader_name' => '', 'follower_id' => '', 'follower_name' => ...

Ruby on Rails 3 and how to make web service

I tried to make this to work, but I got "uninitialized constant ActionWebService" error when I use standard (old) actionwebservice, but if I install datanoise's actionwebservice gem I can't settup project properly to use them (in Gemfile with gem Bundler). There is a alternative? Someone make this think to work? ...

Facebook API - Only retrieve friends of user who are 21+

I'm in need of a way to fetch the friends of a user but only those who are 21+. I'm aware of "admin.setRestrictionInfo" but it doesn't seem to be working. Seeing as how the Facebook documentation is in a constant state of disarray I wouldn't put it past Facebook to depreciate to call and not updating the docs. Any help would be much a...

send_file works but does not let user specify target filename/folder

In my rails application I letting users download files def download options = { :filename => @file_name, :type => 'application/zip', :disposition => 'attachment' } send_file(@path, options) end This works and user sees an Open or Save File dialog. However user is never given a chance to specify neither file name nor a target folde...

ignore before_update when save

some case I don't want execute before_update. please help me. case A: in case I want used before_update obj = Object.find(id) obj.save but case B I don't want used before_update obj = Object.find(id) obj.save # in case I want used before_update ...

time_select with 12 hour time and Time Zone in Ruby on Rails

I have the need to capture a time and time zone from users of a rails 2.3.8 app, but have been unable to think of a clean solution to create and parse the selections. Ideally I would have a drop-down menus for the following: hour (1-12) minute (0-59) AM/PM Time Zone Is there a gem/plugin that accomplishes what I am looking for? Will...

Rails 3 SSL routing redirects from https to http

This question relates to this SO question and answer (rails-3-ssl-deprecation ) where its suggested to handle ssl in rails 3 using routes.rb and routes like: resources :sessions, :constraints => { :protocol => "https" } # Redirect /foos and anything starting with /foos/ to https. match "foos(/*path)", :to => redirect { |_, request| "...

advanced rollover to display extra options

Hi, I have a web app that has a list of user comments. I want extra options for these comments (vote, reply, etc..) to appear only when the comment itself is mouseover-ed The best example of what I am looking for would be a youtube video: http://www.youtube.com/watch?v=s2VzLn6DMCE&amp;ob=av3e When you go to the comments the options...

Get website user time and timezone in Rails

Does rails provide solution to get website user time and timezone configured on his local machine, which is used in his web browser? ...

Rails - text_field_tag ---- setting a tabindex?

With the Rails text_field_tag --- how do you set an option for the tabindex? Thanks ...

Rails cancan authorizing nested resources

I have Projects resource which is nested in Users resource. My Cancan Ability class is: class Ability include CanCan::Ability def initialize(user) #everyone can :read, Project if user.blank? # guest user ... else #every signed in user case user.role when User::ROLES[:admin] ...

Rails 3 - Distinct and Random

I am trying to choose 5 distinct brands from among the cars that belong to my users. My current attempt is below (no approach to selecting at random). @range = @user.cars.select('DISTINCT brand_id').limit(5) How might I select these five random distinct brands? Thank you very much. ...

Using rspec with Webrat instead of Capybara

Hello everyone, I have been using rspec with webrat and decided to add cucumber for high level tests. After installing cucumber with capybara, for some reason rspec also switched to using it. Is there a way to tell rspec to continue using webrat ? ...

Heroku + Logs Command :: Can Logs Detail can be increased at Heroku.

Is it possible to see the last log of Heroku server. I have used heroku logs to see the last process but it shows limited log. But i want to see more process done at heroku. So what command or what process should I follow to see the logs at Heroku. Thanks in advance. ...

Referencing a belonged_to items owner in Rails / ActiveRecord query.

Lets say I have a Person model and a Opinion model. Opinions belong to Person, a Person has many Opinions. Some people are shy. I am trying to find a set of opinions where the person is 'not shy' or something along those lines. Is there a way to do this that does not involve finding all people who are not shy and then finding those p...

Delta indexes not working on servers when using Thinking Sphinx

I'm using delta indexing for my Thinking Sphinx indexes in my Rails project. In my machine (Mac OS X) it's working fine. I change a record and it immediately finds it. On the servers (Debian) it doesn't. I did run a sql query for delta = true and the I've got the expected recently changed records, so that part is working. In the log/sea...

How to prevent logging of certain exception in rails

When there is no database connectivity to the application, I catch the ActiveRecord::RecordNotFound exception in the rescue_action_in_public method and try to render the page which doesn't have any database access. When this happens, I dont want the Mysql:Error exception to be logged, because for the whole period of DB down, this excep...

How to use Cucumber to test content loaded with javascript

I've been developing a Rails application and I've decided to implement a mixture of Test Driven Development and Behavioral Driven Development. However the application I am building uses a web application user interface framework known as MochaUI which is built on top of the Mootools framework. I have just finished writing a portion of...