ruby-on-rails

Ruby on Rails: How to set a database timeout in application configuration?

I'd like to set my database to timeout requests that do not complete within a set amount of time, in order to prevent outlier requests from monopolizing the entire application. Is there anything I can add to my Rails configuration files in order to set this? I tried to add a line I saw often online of timeout: 5000 to my database.yml, ...

Trouble getting text_field_with_auto_complete to work on an overlay

Hey all I have a slight issue with getting Auto Complete to search when the text field is on a modal overlay. To achieve the auto complete I am using the plugin by Pat Shaughnessy (link) and the modal overlay is created using the helpers in the "Modal Overlay" plugin. I am trying to use the auto complete on a form that is displayed in...

warning: getc is obsolete; use STDIN.getc instead

Hello, I'm having a problem with my rails application. When I type script/server I get the following error: /Users/admin/.gem/ruby/1.8/gems/activesupport-2.3.5/ lib/active_support/multibyte/unicode_database.rb:37: warning: getc is obsolete; use STDIN.getc instead This causes the application to hang and not respond. How can I...

Override method for default RESTFUL Routes in Rails

Given a line something like below in routes.rb map.resources :users The routes generated might be something like this: users GET /users(.:format) {:controller=>"users", :action=>"index"} POST /users(.:format) {:controller=>"users", :action=>"create"} new_user GET /users/new(.:format) ...

before_filter in Rails and ajax requests

Hi guys, I have the app based only on ajax calls but i need constantly to check the decreasing value in session variable. I created a before_filter with a redirect_to :action => :action_name for some reason this doesn"t work for me. I see in log Filter chain halted as [:method_name] rendered_or_redirected. but in fact nothing happens. ...

301 redirect to new domain in Rails with NginxHttpRewriteModule, pivotal/refraction, or Rack::Rewrite?

nginx, rack-rewrite and refraction are possible solutions for my migration. It's a simple 1-to-1 mapping from old URLs to a new domain from the old one, e.g. http://old.com/posts/id to http://new.com/posts/id, so hopefully not too hairy. Does anyone have any good/bad experiences with these different approaches or have any comments on ...

Polymorphic assosciation question

Hello! In my Rails app I have models that look something like this: class Blog < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :blog end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true end What I'm having problem with now is finding all comments under a spec...

Displaying the next lines and white spaces in HAML

I use a text area to collect comments from the user. The text area preserves the next line and white space indentation. While displaying the comment in a p tag the next line and white space indentation at the beginning of the line are lost. I enter the following text in the text area: Lorem ipsum dolor sit amet, consectetur adipisic...

Where can I read about how Ruby on Rails is structured?

I've been looking at questions like these but I'm not really finding what I'm looking for. I'm a web developer with a fair bit of expertise in other environments (Java, Python, PHP, etc.) and I tried to pick up Rails awhile back. I was incredibly frustrated by the way the guides I found would say things like "put this line of code over...

method throws an argument error the second time it gets called?

Hi I have the following method that retrieves all the appointments between 2 dates: def self.search_app(start_date, end_date) if start_date start_date = Date.new(start_date['(1i)'].to_i, start_date['(2i)'].to_i, start_date['(3i)'].to_i) end_date = Date.new(end_date['(1i)'].to_i, end_date['(2i)'].to_i, end_date['(...

Facebooker before_connect(facebook_session) causes http error with email

Hi, I am using the facebooker authlogic plugin. I have it working pretty well now. However, any attempt to set the email address in User.before_connect(facebook_session) is causing a Apache to throw the following error: Premature end of script headers: person_session, referer: (person_session is my user_session). Here is the code for...

Show Different Home Pages Based on Logged In Status in Rails

I'm using the restful authentication plugin to authenticate users for an application I'm building. As in most good sites when a user visits the homepage I want to show a boilerplate welcome page and have the option to login or signup. However when a user is logged in I want the root url of the site (i.e. sitename.com ) to show a user das...

remote form_tag in rails3 without a named route

what is the proper incantation to make this actually post asynchronously? form_tag :controller => :magic, :action => :search, :method => post, :remote => true do method=post and remote=true just get squashed on the end of the url instead of actually making it an ajax post. ...

RoR testing controllers

I use RoR 3 and i guess something changed in controller's tests. There is no def test_should_create_post but test "should create user" do ... end Is there any decription how is that mapping etc? Because i dont get it. And second thing. How to program (what assertion) use to test login? ...

Ruby on Rails 3: Streaming data through Rails to client

Hi, I am working on a Ruby on Rails app that communicates with RackSpace cloudfiles (similar to Amazon S3 but lacking some features). Due to the lack of the availability of per-object access permissions and query string authentication, downloads to users have to be mediated through an application. In Rails 2.3, it looks like you can ...

Why is ruby on rails returning null instead of json object

I'm new to Rails so this is really basic and I'm sure I'm missing something simple. I'm trying to send some JSON to an action and get it to return a response in JSON. A simplified version of what I'm trying is below. The jQuery I'm using: var request = { 'voter': { 'voter_name': 'John', 'voter_email': '[email protected]'} }; var url = '...

Can I count based on virtual attribute?

I have the following error: no such column: company_name: SELECT count("contact_emails".id) AS count_id FROM "contact_emails" The model ContactEmail does NOT have a column company_name. I created it as a virtual attribute. It's not possible to do a select based on that information? How would I do it, then? ContactEmail belongs_to...

Rails: how are paths generated?

In Rails 3, when a scaffold is generated for instance for a 'Category' the will be a categories_path (and a edit_category_path(@category), ...) used in the erb views. This is not a variable that can be found anywhere and probably is generated. However in my case, for a different entity, Article, I first generated the model and then the ...

Can I have plugins within my Rails Engine?

I have 3 rails apps that currently use a "shared" rails app (complete rails app generated). They shares the model, controller, initializers and plugins from this app. So its time to convert the shared application to a rails engine! (less symbolic links). My question is this, how can I share my plugins among multiple applications in thi...

Textile question: redcloth anchor links

How do I write this in textile (i'm using the redcloth gem) <a href="#tips">Visit the Useful Tips Section</a> <a name="tips">Useful Tips Section</a> I know the first part, "Visit the Useful Tips Section":#tips but how do I make the named anchor? Thanks! Deb ...