ruby-on-rails

What should my Nginx rewrite rules be for Rails with Passenger for page caching in a subdirectory?

I'm using Nginx 0.7.64, Passenger 2.2.9, Rails 2.3.5. I have my page caching directory set to /public/cache, and I'd like to be able to serve cached pages when requested over HTTP, but always hit the Rails app when requested over HTTPS. The bulk of my config looks like this: server { listen 80; server_name website.com www.website....

Can delayed_jobs create delayed_jobs?

I'm trying to figure out if I'm able to use delayed_job. I would need the ability to add jobs to the queue within a delayed_job perform method. Is this possible? ...

how to beautify validations in rails

I have a simple scaffold rails application that is doing validataes_presence_of. The validation is making each textfield bordered. I just want the error messages to be displayed on top. How can I make these type of changes or color changes to the validation ...

Ruby on Rails Rake Error

EDIT: Solved the problem, thanks to this forum post: http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407. Thanks everyone! I've started learning RoR and have been trying to use rake db:migrate but I keep getting the same error. I can connect to the MySQL database using C:\dev\railslist>mysql ...

Automatically reload rails module

I'm developing a ruby module that I include in my rails app. I want it to be reloaded automatically when it changes. I've done extensive googling, and looked at the various questions here that discuss it, but they all seem out of date or wrong. How do I get an external module to be reloaded in rails when it changes? I've tried adding it...

Beginner Rails Queston : Controllers and Route

I'm very new to Rails. Q1. What is the route between controller and view? Let's say I have a controller called store_controller. I have no method in that controller but I have a view called "list" then, I'm able to call localhost:3000/store/list ... Why am I able to call this without having list action in controller? Q2. What if I...

Parsing Word docs with Ruby

Is there a way to parse word documents (doc and docx) with Ruby? I've a linux server and running a rails website that requires this service. ...

Rails/ActiveRecord: Return order with ActiveRecord#find(Array)

Hello, I'm using Ruby on Rails/ActiveRecord and am having trouble with an ActiveRecord#find call. I'm storing in the database a serialized array of recently viewed documents IDs. The IDs are stored in descending order of when they were last viewed, so the most recently viewed document ID is first in the array. The array includes 10 I...

Rails: Split and wrap each character in a string?

I have something like: <%= @votes %> With just outputs a string like: 123 Is there a simple way to wrap each character with some html with a helper? <span class="outerclass"> <span class="innerclass"> 1 </span> </span> <span class="outerclass"> <span class="innerclass"> 2 </span> </span> <span class="outerclass"> <...

How to hold submitted form data until it's been reviewed?

Hello, I am a complete newb at ROR and intermediate at best with programming in general (mostly PHP). I'm trying to build my first web app as an experiment which is a job posting site. The largest feature and pretty much the only feature is to have a user create a posting, review it then pay for it before it is posted. I ran the sc...

Storing Surveys in CouchDB vs. MySQL

Hi there, I am looking into the best ways for storing surveys to a database with Rails. I have checked out this great Smerf Survey Plugin for Rails which stores surveys into a Relational Database with the following tables: smerf_forms: name, code smerf_forms_users: user_id, smerf_form_id, responses (as text) smerf_responses: smerf_f...

Having issues with rspec and factory_girl validations and associations

To start out, here is the failing message: ActiveRecord::RecordInvalid in 'Event should be valid' Validation failed: Single access token has already been taken, Login has already been taken, Email has already been taken Here is my factory: Factory.define :valid_event, :class => Event do |e| e.event_date "2010-01-01" e.critter { |...

Replace white space with AND in ruby

I have someone entering a form with some string input. What I need to do is replace any white space in the string with " AND " (no quotes). What's the best way to do this? Also, how would I go about doing this if I wanted to remove all the whitespace in the string? Thanks ...

Assistance with Some Interesting Syntax in Some Ruby Code I've Found

I'm currently reading Agile Web Development With Rails, 3rd edition. On page 672, I came across this method: def capitalize_words(string) string.gsub(/\b\w/) { $&.upcase } end What is the code in the block doing? I have never seen that syntax. Is it similar to the array.map(&:some_method) syntax? ...

How do I make an exclusive rather than inclusive query with named scopes in Rails?

I've created an application that finds service providers based on multiple services passed to it. This is done via has many_through so there is a join object. Basically, if a user asks for service providers with Service A and Service B my scope returns service providers who offer either BOTH Service A and Service B or other service provi...

[Rails] Using find method to find NOT matching

I'm trying to look up a User by group_id. My method looks kinda like this: User.find(:all, :conditions => {:group_id => '90a39597a1aa3ec65fccf29ae05d9b6aefbfea6b', :id => !current_user.id}) The :id condition doesn't make sense because I don't know the syntax for this part. How would I find a user by group_id and :id which doesn't matc...

how to rest my app to support mobile phone

I am now going to develop a mobile website both support common html format page and wml format page(Because now a usual web browser on mobile can view html page and some old mobiles only support wml ) First step: register content type for wml page config/initializers/mime_types.rb Mime::Type.register_alias "text/vnd.wap.wml", :wml Sec...

What language does twitter and facebook use?

hi gurus! I'm using php for the last 6 months and i can pretty much do anything with it. But BIG websites like Facebook and Twitter doesn't appear to use php. I wanna know what languages they use and why they chose that language over php. Is Ruby on Rails a good language to build robust and big websites? I've seen RoR's video on youtu...

Adding new field to pre-existing table and modifying previously created data in Rails

So I've a user model and a corresponding table (users) with fields: User_id, username, password etc. But then I added invitation_limit to users table. Newly created users have invitation_limit, however the users created before the invitation_token migration was run don't have the invitation_limit field. How do I update the previously c...

Installing Ruby on Rails in windows 7

hi! I saw some ruby tutorials today and like to learn it. The problem is that i'm stuck with the installation process! :( I can't get a clear picture on how to install RoR. For example, to write php code i installed wamp and straight away started writing php scripts. And i'm using Dreamweaver CS4 as an IDE. Can anyone enlighten me : ...