ruby-on-rails

Disable transactions in ActiveRecord

How do I disable transactions in Rails' ActiveRecord? I have a specific situation where I want them to go away I can't seem to find anything useful out there. Is it even possible? ...

acts_as_tree and to_json or from_json

Hello: Does anyone have a solution to convert an acts_as_tree model to json that includes all its nodes? I trued using :include=>:children, but that only goes down to one single level. Any idea how to iterate the whole tree? ...

Why use a Rails-like deployment mechanism over 'git pull' for releasing?

To release my centralized webapp, I COULD have a vhost pointed to some directory and then just do a 'git pull' when I want to release, updating the files. But Rails has a different deployment mechanism: it copies files to a subdirectory and then points a symlink ('current') to that new subdirectory. I understand that it probably more ac...

undefined method `call' for LiquidView:Class

I trying to use Liquid template engine plugin , but I 'm getting the following error while controller tries to render a .liquid template . "undefined method `call' for LiquidView:Class" product_controller.rb @product = Product.find(:first) render :layout=> false, :template=> "product/show.liquid" product/show.liquid Product name : {{p...

How do I set the session cookie's HttpOnly setting to false?

In Ruby on Rails, how do I set the session cookie's httpOnly setting to false? ...

Serve Images from Asset Host When Using CSS background-image property in Rails

I recently started serving static assets (mainly images) from an asset host for my Rails project. A small portion of my images are not being served from the asset host because they are displayed using the CSS background-image property rather than image_tag Is there are clean workaround for this? I'd rather not create a "stylesheets"...

ActiveMerchant - Optimal method of sending money to user? PayPal account or Credit

I have a website that will take payments from user A, hold them in our escrow account, then transfer the money minus a fee to user B. I have the first part figured out, in terms of taking credit card payments from user A, but I'm trying to figure out the optimal method of taking that money and sending it to user B. I'm not storing cred...

Ruby on Rails: how to get error messages from a child resource displayed?

I'm having a difficult time understanding how to get Rails to show an explicit error message for a child resource that is failing validation when I render an XML template. Hypothetically, I have the following classes: class School < ActiveRecord::Base has_many :students validates_associated :students def self.add_student(ba...

Render public html for dynamic banners in Rails ?

Hi, I would like to render specific HTML snippets for displaying banners, because each banner has a different nature (some images, some flash, etc). Every banner file is under app/public/banners/. I tried many ways, like: render :file => "/banners/somebanner.html" But it can't locate the file, because Rails looks under app/views. Any ...

Python vs Ruby Top Sites

Hi, I was just trying to find some comparison of the existing python web frameworks and ruby frameworks. There are few promising frameworks in python but I was not able to find a top 100 site using python except for google, which uses python extensively. Python has great frameworks but I am not able to find a really popular sites usin...

NoMethodError for underscore

I want to convert the string "Full Time" to "full_time" When I using "Full Time".underscore in irb, it prompt a error NoMethodError: undefined method `underscore' for "Full Time":String How can I fix it? Or is there any other way for me to get the above underscored result? ...

What would you like to see in a book about Rails 3?

Hello, Now that I'm quite a ways into this book I can announce that it's Rails 3 in Action. I'm thinking of writing a book about Rails 3 and I have a basic idea of what I want to write about, but really what I need is that little bit of polish from the community. The book is planned to cover: A little bit of Ruby Version control usin...

should_receive in RSpec

As far as I know, should_receive is applied only to mock objects. What I want is to check, if a certain Class (not object) received a certain message, like: User.should_receive(:all).once How do I do that? UPD. Commonly, writing test for models and controllers we can write User.should_receive(:smth).once. But in my case I'm testing a...

Exclusive filtering by tag

I'm using rails 3.0 and MySql 5.1 I have these three models: Question, Tag and QuestionTag. Tag has a column called name. Question has many Tags through QuestionTags and vice versa. Suppose I have n tag names. How do I find only the questions that have all n tags, identified by tag name. And how do I do it in a single query. (I...

Rails application installer

Hi, I am making a rails cms and I have wondered if there is a plugin or script, which automatically installs the application? Thanks! ...

Haml - if-else with different identations

I'm trying to render a calendar with Rails and Haml. The dates used come from a variable called @dates. It is a Date range that contains the first and last days to be presented on the calendar. The first day is always Sunday and the last one is always Monday. I'm planning to render a typical calendar, with one column per weekday (Sunda...

api.rubyonrails.org is out?

Is just for me or the site http://api.rubyonrails.org/ and the whole rubyonrails.org domain are being redirected to a spam website? I just realized it today when i went to answer a question here at stackoverflow. ...

Authlogic LDAP : encrypt communication

Hi, I have a rails app with authlogic and LDAP, but my problem is i can see all the users password on the log file, is there something to fix to encrypt those passwords. For ldap i use :encryption simple_TLS Thanks for your help ...

Database nesting model layout confusion

I'm no expert in databases and a beginner in Rails, so here goes something which kinda confuses me... Assuming I have three classes as a sample (note that no effort has been made to address any possible Rails reserved words issue in the sample). class File < ActiveRecord::Base has_many :records, :dependent => :destroy accepts_neste...

Finding records that overlap a range in Rails

So, I have an Event model that has a starts_at and a ends_at column and I want to find events that take place in a range of dates. I've come up with this named_scope (range is typically a month): named_scope :in_range, lambda { |range| {:conditions => [ 'starts_at BETWEEN ? AND ? OR ends_at BETWEEN ? AND ?', range.first, rang...