ruby-on-rails

Development VPS where environment (Ruby/Rails, Javasciprt/Node.js etc) is pre-installed?

Until now I'm setting up my own development environment with Vagrant/VirtualBox/Chef (Ruby). I wonder if there is a hosting company that provides pre-configured VPS for... Ruby/Rails Javascript/Node ...letting me just choose what I want to have installed and also which linux packages I would like to install in each VPS. Are there h...

Rails multi-model form for new record

Hello I am trying to create a web app for a clothing store, where the store admin can generate lists of options for different products. For example, the admin can generate an option_list called 'bra sizes' and then attach options to that list. I have two records: class OptionList < ActiveRecord::Base has_and_belongs_to_many :product...

How does one create a scope to find "Authors who have zero posts"?

Using Rails 3, this scope works as would be expected: scope :with_posts, lambda { joins(:posts). select("authors.*, count(posts.id) posts_count"). group("posts.author_id"). having("posts_count > 0") } The generated SQL is: SELECT authors.*, count(posts.id) posts_count FROM `authors` INNER J...

What is the best development environment for Ruby on Rails?

Hello, I am a person who is completely new to the Ruby on Rails coding language. A friend and I were going to get our feet wet, but instead now want to jump right in. What would be the best development environment for Ruby on Rails? I am on a Windows machine and my friend is on a Mac. I have the Eclipse development environment for Ja...

Rails Return Error on Class Method

I have a class method that I would like to return a error from, is something like this possible? class Foo < ActiveRecord::Base def self.do_this if b = Bar.find_by_id(5) return 'Yea' else self.errors.add_to_base('I was not found') end end end ...

(Rails) How to implement search when all metadata is found in has_many_polymorphs models

Hello, I have a Page model. The Page model consists mainly of just the page name, however the actual page content is made up by many page components using has_many_polymorphs. Each of these page components also has a name and the linked component may contain more data, such as date values, textual content, images or other files. This h...

Rails belongs_to many models

I did find some questions on SO about Rails associations that are somewhat like my question, but for the life of me I can't seem to understand how to use belongs_to multiple models. Here's the table structure I intend to have: User id Post id user_id #foreign key; a post belongs to a User aka "Who created this post" Comment id u...

Parent page gets reloaded when opening colorbox which renders partial returned from rails

A colorbox is launched with: $.colorbox({href:'appointments/admin_index'}); Which calls a controller that returns a partial ('admin_new'): respond_to do |format| format.html { render :action => "admin_new" } end This works in that the colorbox renders the correct partial, however it also causes the main page to partially reload a...

how Customice rails Devise gem for Deferent model

I have problem in my application i need to use devise for my application there are different user levels i need to edit User controller in devise plug-in ...

nginx be both reverse proxy and web server

I currently use nginx with passenger to serve my rails app. considering including a caching reverse proxy to the equation. Can I use the same instance of nginx as a reverse proxy (running on port 80, serving static as well as e-tagged actions) as well or would I need a different instance of nginx or a totally different type of reverse pr...

page_cache_fu error

I am getting an error when I am starting rails server in rails 3.. undefined method `to_prepare' for Dispatcher:Module (NoMethodError) How to solve this issue ? Please help ...

Which is the best route to take when uploading images from my Rails app to Amazon's S3?

I have a web app in which users can upload an avatar under 700kb. That's the only part of the application dealing with uploading images (so I won't be dealing with an exceptionally heavy load). I was wondering what the best way is to go about this. Currently I'm using Paperclip and I wan't to store all of the images on Amazon's S3. Opti...

Capistrano user-related problem

Hi, I'm deploying a rails application using Capistrano to a shared server (on WebFaction). This means there are several different Ruby version installed there. Everything works fine until I want to run some rake tasks. These tasks fail by saying I don't have the right RubyGems version. From this thread I understood that fixing it woul...

ActiveRecord::RecordNotFound in MembersController#show

Hi, I am sorry for my bad english first. I just installed ruby and rails few hours ago (you wouldn't believe it took me 3 days to install ruby,rvm,rails and etc, on this ubuntu 10.04 machine) and I am trying to implement basic Member scaffold. My version of rails is 3.0.0 and my ruby is 1.9.2. When I #rails generate scaffold Member em...

How to generate documentation with Yard for Rails views?

I have just started using Yard to generate my docs and whilst it works great for my models and controllers, I can't seem to get it to generate anything for the views I've tried a variety of different ways to get it to work. Currently I've set up a rake task to generate the docs that looks something like this YARD::Rake::YardocTask.new...

Turn on html_safe for the entire app in Rails 3

Rails 3 turns off the html_safe option by default. I want to revert this thing. I have a rails 2.3.8 app getting converted to rails 3. Almost every page breaks because of the rails3 default html_safe setting. Is there any way I can revert this to where it was in previous versions of rails ? Please help ...

click_link image in cucumber

<a href="/videos/21-running"> <img height="120" src="/images/sample-image.jpg" alt="Running"> </a> Please support me a way click link in cucumber by alt or src. Thanks. ...

N+1 problem in mongoid

I'm using Mongoid to work with MongoDB in Rails. What I'm looking for is something like active record include. Currently I failed to find such method in mongoid orm. Anybody know how to solve this problem in mongoid or perhaps in mongomapper, which is known as another good alternative. ...

How disable encrypting password in devise?

Hi! How disable encrypting password in devise? ...

Selecting from across multiple tables in Rails

Say I have Apples, Oranges and Melons, and each has a column "created_at". How would I construct an ActiveRecord / SQL query to find the 10 most recent Apples, Oranges and Melons? Is there an elegant way to do this? ...