ruby-on-rails

RoR facebox for prototype

Hi, I've got facebox working using the following tags in my rails app <%= link_to 'test' some_path, :rel => 'facebox' %> Now that works perfect if the page is already loaded. However, I have ajax updates on certain parts of the page which contain new links like the one shown above. When you click the links from an ajax update faceb...

Store data from filled form

Using restful_authentication and before_filter :login_required, :only=> [:create] on controller: Is it possible to store data from form, and after user logged in, continue with 'create'? So i mean: User logged off and he see Somecontroller#new Then he fill in the form Then he press "Save" As we have login_required, user now has ...

sense of RESTful requests

Hi, I have a ruby-on-rails application and I'm now wondering why RoR uses Restful Requests: eg. if you want delete an ressource it's a best practice to do it with such an HTTP Request: DELETE /entry/13 you can also do it with with such an normal request: GET /entry/delete/13 or GET /entry/13/delete now my question: when i make a li...

[REST] is it bad form to have the colon in db and in the URL?

I am designing my namespace such that the id i am storing in the DB is id -> "e:t:222" where "e" represents the Event class, "t" represents the type i am also expecting to use this id in my urls url -> /events/t:222 Is there anything wrong with doing this? ...

how to mongoid projects <=has_many=> users

Hello all, I just began using Mongoid last week. I am running into this association problem which I am unsure if my approach is correct. So i thought I would ask for some opinion I have a User model and a Project model class User include Mongoid::Document field :email end class Project include Mongo...

Combine MongoDB and Postgresql in Rails?

Is it possible to combine AR with MongoMapper/MongoID? If so, are there tutorials/documentations for this? ...

How do I implement this code without needing to access current_user.id from a model in RoR?

I have a note model, with the following association note.rb has_many :note_categories, :dependent => :destroy has_many :categories, :through => :note_categories The NoteCategory model was created to function as a join table between notes and categories. I need to implement the following: A user removes a category from a note. Thi...

recaptcha plugin for rails

I am currently using ambethia's recaptcha plugin for rails. I want to disable the message "incorrect-captcha-sol" whenever the user incorrectly enters the wrong recaptcha. How should I go about doing this? In the source file I get the following tags surrounding the error message <p class="recaptcha_error">incorrect-captcha-sol</p> ...

RSpec Argument Error

I'm getting an argument error whenever I run an RSpec test on any controller action that uses a POST or PUT action. It's happening on all of the controllers, no matter what I do. It's just the "wrong number of arguments (1 for 0)" one. The app is working, but the tests are all failing. I think this is happening whenever a "save" is call...

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....

ASP.NET MVC: Passing instance variables to the View like in Ruby

Yes, I know that in ASP.NET MVC you have to use ViewModels. But I'm tired of writing countless amounts of ViewModel classes. Besides I'd like to just pass the Validation model to the view, instead of that I have to pass the whole ViewModel, so I get ugly code like Html.TextBoxFor(m => m.TopicModel.Title) Instead of Html.TextBoxFor(m...

What are all the "conventions" for Ruby on Rails?

I'm a Django person going into Rails, and I want a guide that shows me all the popular "conventions". For example: plurality, _form.html.erb, stuff like that. Can someone list them here? Or a webpage? ...

appending to content_for in rails

We are currently in the process of refactoring our site and we have decided to just go with one js library (jquery). Problem is, due to time constraint, we can only do so much so at the moment, we have to make them coexist. This is easy since we have jquery's no conflict method, so I can just declare jquery then do the no conflict thing...

What does this line mean in Ruby?

def show render :text => params.inspect end What is render :text =>? What is render, :text, and the =>? Are they standard ruby? ...

Rails Arel selecting distinct columns

I've hit a slight block with the new scope methods (Arel 0.4.0, Rails 3.0.0.rc) Basically I have: A topics model, which has_many :comments, and a comments model (with a topic_id column) which belongs_to :topics. I'm trying to fetch a collection of "Hot Topics", i.e. the topics that were most recently commented on. Current code is as f...

Is there a tool for assisting with ruby/rails internationalization?

I'm looking for something that will help me to internationalize an existing rails application using I18n. Ideally it would locate string constants (with parameters) and allow me to extract those into a .yml or .rb file replacing the original string with the appropriate t(...) call. Also, or alternatively, a macro to do the same on select...

wrong class_name selected by ActiveRecord

Hay fellow developer, When I invoke @chapter.articles, rails yields the following error: uninitialized constant Sommaire::Chapter::Article Event if I specify *:class_name => "Sommaire::Article"*, it yields: uninitialized constant Sommaire::Chapter::Sommaire::Article Since I'm relatively new to rails (3.0.0), this has lost me ! Th...

Good explanation about how rails works behind the scenes?

Hi I was wondering if there was any good articles out there that explain how the architecture of rails works, i.e how it handles the server connection, how it queries the database so easily etc. ...

Easy way to examine browser name and version

Hi, Is there any really easy way to get to know, what browser has called controller's action. I would like to have a code for my controller, like this: if mighty_lib.browser.name == "Safari" if mighty_lib.browser.version >= 5 # Glad to see you, Safari 5, there is a stunning, interactive page for you. elsif mighty_lib.brow...

Constucting a PostGIS query with Rails

I'm using PostGIS (1.5.1) with Rails (3.0.0rc) and a Google Map (v3), and I'm looking for a way to query the database to retrieve all the points within a polygon (specifically, the bounds of the map viewport). At present I am sending the coordinates of the bounds to the server as such: google.maps.event.addListener(map, 'bounds_changed'...