ruby-on-rails

Active record model with remote data storage

I want to implement a model "Contact", whose data is not stored in database, but remotely. The operations on data are done via web service. The model Contact is related to other models, whose data is stored locally. Is there any plugin/gem which can take care of this? Regards, Pankaj ...

In RoR, is there an easy way to prevent the view from outputting <p> tags?

I'm new to Ruby and Rails and I have a simple controller that shows an item from the database in a default view. When it is displaying in HTML it is outputting <p> tags along with the text content. Is there a way to prevent this from happening? I suppose if there isn't, is there at least a way to set the default css class for the same ou...

Passenger apache default page error

I asked this a couple of days ago on Server Fault but am getting no responses and little interest. Since it is related to setting up a dev environment I thought the SO community might be able to help me out... I just installed Passenger and the Passenger Pref Pane on OSX. However, when I try to browse to one of my Rails applications I...

How to split europe word in rails?

btw I used utf8_unicode_ci for example I want to split this sentences a = "Die Wirtschaftswissenschaften können Märkte nicht berechenbar machen" b = a.split("können Märkte") b => "Die Wirtschaftswissenschaften können Märkte nicht berechenbar machen" if I split the regular text b = a.split("Die Wirtschaftswissenschaften") b => "könne...

heroku time zone problem, logging local server time

UPDATE: Ok, I didn't formulate a good Q to be answered. I still struggle with heroku being on -07:00 UTC and I at +02:200 UTC. Q: How do I get the log written in the correct Time.zone ? The 9 hours difference, heroku (us west) - norway, is distracting to work with. I get this in my production.log (using heroku logs): Processing Pro...

Textmate is garbling Rails test output

Instead of colors I see this.. Anyone know what might be causing this? ...

How are SaaS applications organized?

Consider web (MVC, for example Rails) application for multiple clients as a service. How to design this? one application instance per client? (+ one database per client) one instance for all clients (+ one database for all clients) Former one is simple, but... "inefficient". How about the latter? (best practices, design patterns) H...

Rails - How do I write this string condition as an array condition

named_scope :correct, :include => :correction, :conditions => "checked_at IS NOT NULL AND corrections.id IS NULL" On a side note I have googled loads and looked through books but i cant seem to find a list of all the various types of conditions you can use and how they differ when implenting them as strings, arrays or hashes. Is there...

Comparison of databases on the performance of Ruby on Rails

It is well-known that Ruby on Rails offers a list of choice on database adapters, like MySQL, PostgreSQL, Sqlite, MSSQL, Oracle, DB2. All of them offers the same basic set of SQL on CRUD. Is there any comparison on their performance when running a typical Ruby on Rails application? ...

List of attributes from class and include module

I have a class (ActorClue) that has three attr_accessor defined within it. There are a couple other common fields needed by other classes, so I put those common fields in a module (BaseClueProperties). I am including that module within my ActorClue class. Here's the code sampling : module BaseClueProperties attr_accessor :image_u...

jquery multiple select x rails edit action

Hi, i'm using the JQUERY multiselectable plugin. Because it's get one select box and transform it in two, where you can move one selected option to another select box. The problem is that i'm facing some problems with the edit action. When i load the form, the selected values (that are saved in my model) are not being populated in th...

Sqlite3 activerecord :order => "time DESC" doesn't sort

rails 2.3.4, sqlite3 I'm trying this Production.find(:all, :conditions => ["time > ?", start_time.utc], :order => "time DESC", :limit => 100) The condition works perfectly, but I'm having problems with the :order => time DESC. By chance, I discovered that it worked at Heroku (testing with heroku console), which runs PostgreSQ...

Rails - Why is my custom validation being triggered for only a build command.

I have a sentence and correction model with a has_one and belongs_to relationship respectively. For some reason when I do def create @sentence = Sentence.find(params[:sentence_id]) @correction = @sentence.build_correction(params[:correction]) a custom validation I wrote for Correction is being called at the build_...

passing text_field values in ajx on rails

I'm using <%= text_field 'person', 'one',:id => 'test', :onchange=>remote_function(:url=>{:action=>"update"}, :update=>"test") %> <div id="test"></div> Now I just want to send the value of text_field with :action i.e :url=>{:action=>"update(value_of_text_field_entered"} Don't want to use params[:person][:one]. Any suggestions?or ho...

Rails - validates_uniqueness_of model field with the inverse of :scope

Hi - I'm trying to validate uniqueness of some field in my model with one catch - it shouldn't raise an error if records have some shared relation. For the sake of example, here's what I mean: class Product < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base has_many :products end >>> Category.crea...

Can I have both index and create actions in the index view?

Hi all, Using the perennial example of a Blog webapp (and all resources are currently automatically mapped in routes.rb): I have a simple index page that lists all my Post titles. I would like to add a form at the bottom of this page to quickly create new Posts. I'm new to Rails and can't seem to figure this out! Please help! ...

undefined method `content_type' for nil:NilClass /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb

Strange error in diagnostics.erb file about _set_controller_content_type. Please help. NoMethodError in Timelines#public_timeline Showing /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb where line # raised: undefined method `content_type' for nil:NilClass Extracted sourc...

how to organize javascripts using rails and jquery

Hi, i'm working in a big and rich rails web application using tons of javascript. I would like to know if anybody has a tip to organize the javascripts. Today i'm generating a new file named controller.js and adding it to my views using content_for. The problem is, some files are becoming big and sometimes, i need a function from one co...

problems with build params for accepts_nested_attributes_for

I'm trying to add the user_id to a nested attribute that gets built by a parent controller but it doesn't seem to have the desired effect? Ie. I have a model called Place.rb which accepts_nested_attributes_for :reviews and has_many :reviews, :as => :reviewable, :dependent => :destroy The nested attribute works fine and I build it insid...

Ruby on Rails - Send JavaScript to view

Hey, I am creating a website in Ruby on Rails. I have a controller action that renders a view like so: def show time_left = Time.now.to_i - 3.hours.to_i @character = current_user.characters.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @character } end end This is f...