ruby-on-rails

How to add conditions to thinking-sphinx search?

Hi, I've recently installed thinking-sphinx on my ruby on rails app. As first sight, everything works great, I can search words and it will find them. Now, when I try to add some filters(such as, for example, provinces, categories, etc) using: MyModel.search 'hello' :conditions => 'category_id=1' for example, it will throw me the foll...

Pretty URL in Rails when linking

Let's say I have a Ruby on Rails blogging application with a Post model. By default you would be able to read posts by http//.../post/id. I've added a route map.connect ':title', :controller => 'posts', :action => 'show' that will accept http//.../title (titles are unique) and the controller will do a query for the title and display t...

Cucumber and webrat - How to handle dynamic URLs in the paths.rb?

I am using Cucumber for BDD development in my Ruby on Rails project and I'm running into some confusion on how the path.rb handles paths used in rails applications. Given I have: class Parent < ActiveRecord::Base has_many :children end class Child < ActiveRecord::Base belongs_to :parent end and I have the following Cucumber feat...

Ruby on Rails keyboard shortcuts

Hi all - does anyone know how to set-up keyboard shortcuts using Ruby on Rails on my website? For example if a user want to interact with the site using keyboard shortcuts instead of clicking buttons/links how would I do this? Any help is greatly appreciated. Max. ...

Ruby on Rails keybard shortcuts

Possible Duplicate: Ruby on Rails keybard shortcuts Hi all - does anyone know how to set-up keyboard shortcuts using Ruby on Rails on my website? For example if a user want to interact with the site using keyboard shortcuts instead of clicking buttons/links how would I do this? Any help is greatly appreciated. Max. ...

What's the best messaging plugin for Rails?

I need some standard messaging functionality in my app (i.e. messages received, messages sent, read/unread, trash, etc.) I've found a few promising leads - acts_as_messageable, has_messages, ActiveMessaging. I'm leaning toward has_messages. Any experience using these plugins? What's the best choice here? ...

Change starting id number

I have an 'Account' model in Rails with its corresponding 'accounts' table in the database. If I wipe the database and start over, the 'account_id' field will always start at 1 and count up from there. I would like to change the starting number, so that, when the very first account is created in a fresh database, the 'account_id' is, s...

What does Rails mean when it reports spending time rendering a view?

Here's an excerpt from my Rails log: Rendered songs/_song_list (683.4ms) Completed in 841ms (View: 633, DB: 159) | 200 OK What does Rails mean when it reports spending 633ms rendering the view? In this particular case I'm iterating through a collection of items and printing an <li> for each (as the name of the partial suggests) -- is ...

How to map 2 db columns to one property

Given a migration class CreateTalks < ActiveRecord::Migration def self.up create_table :talks do |t| t.integer :duration_hours t.integer :duration_minutes end end def self.down drop_table :talks end end and model class Talk < ActiveRecord::Base end and object class Duration attr_accessor :hours,...

Rails: Return a 401?

I'd like to return a HTTP 401 error as part of my permission_denied method for declarative_authorization. # triggered when a user accesses a page that they don't have access to def permission_denied # render my default 401 error page? end How would I do this? (Pardon the question if it's stupid... I know how to render the 401.html p...

Can't get Rails :autosave option to work on models

This may be something totally simple, but I can't for the life of me get this working. For some reason, :autosave isn't actually autosaving underlying models. Here is my schema: create_table :albums do |t| t.string :title t.text :review t.timestamps end create_table :songs do |t| t.integer :album_id t.string :name ...

Real Life examples of Sinatra applications

Im getting interested in Sinatra to develop micro web applications. I'm not sure where to draw the line when choosing between Sinatra and Rails. Please can you provide some real life examples of applications in Sinatra in the web? ...

Rendering an html table with ajax, JQuery, and render :partial

Hi all- Here is my question. I want to create a table with a specific header row that looks like this <table> <tr class="table-header"> <th></th><th> Name </th><th> Location </th></tr> ..data.. </table> The problem comes when i want to do an ajax populate of the table rows. I have tried a couple options. Basically my app knows wh...

Any Ruby on Rails equivalent to Pinax?

Pinax is: An integrated collection of Django applications that provides the most commonly needed social networking features, including openID support, email verification, site announcements, user-to-user messaging, friend invitations, interest groups with discussions, wikis, and more. Cloud27 is a demonstration of Pin...

Heroku in real life apps

What is your experience using Ruby on Rails on Heroku in production mode? Apart of the issue of the expensive https, do you see any drawback in the way it manages processes, memory and storage? The people at Heroku is quite nice and I'm sure they are willing to answer my questions, but I would like some opinions in the customer side. ...

rails nested object form and namespaced controller

i have a nested object like this: class Work < ActiveRecord::Base belongs_to :issue belongs_to :author has_many :pages, :class_name => 'Work' accepts_nested_attributes_for :pages, :allow_destroy => true end class Page < ActiveRecord::Base belongs_to :work end and i have a form to create/edit a work, with fields for the nest...

Does MongoMapper (or any other Mongodb adapter) have a method like "accepts_nested_attributes_for"?

Hi there, I'm considering using mongodb on a new project, but before delving in, I'd like to know if it supports some key features. I know you don't need migrations, and you can add embedded objects,...but does all that mean it also behaves as if the 'accepts_nested_attributes_for' method is always there? Do you know of any other killer...

How large can a HTTP form parameter string be?

How large can a HTTP form parameter string be? If I want to pass say a couple of pages worth of XML will a form parameter be ok? Or if not would I need to treat it as a file upload to be sure? Thanks ...

How to override html formatting in validation errors in Rails?

I'm wondering if there's a way to remove the formatting created by rails validations? My HTML is below, but basically if there's an error it'll format my errors in the built-in rails way... yet I'd like to have it not. For example, in the below, the password_field would be formatted differently in the event of an error (I don't want th...

Rails: How to handle data when there's an error on create

So I have a subscription form where a user is simultaneously creating a new account plus subscribing to a monthly plan. So they're entering username, email, password, and all the usual credit card/billing info. But the problem I'm having is say they accidentally enter an incorrect credit card number...what's the best way to handle that...