ruby-on-rails

Authlogic plugin with Rails 3 and Ruby 1.9.1

How do i set up authlogic plugin in my application run on rails 3 and Ruby 1.9.2 . ...

validates_associated and HABTM

Article HABTM authors In Article model, i say: validates_associated :authors But, by creating of the new Article, this validation does't happen, because i don't see the errors. Another errors are displayed properly, but this. I render errors so: <div class="errors"> <%= article_form.error_messages %> </div> What's wrong here...

ar_mailer on Ubuntu 10.4

i installed the gem ar_mailer and adzap-ar_mail into my Ubuntu 10.4. the gem got successfully installed. when i run "ar_sendmail" in the command prompt it says ar_sendmail: command not found error. I installed the same gems and plugin into ubuntu 8.4 . it works well. so , i don't know it relate with ubuntu version related issue or else...

Rails AJAX ERB View Question link_to_remote

Rals 3.0 My question is using link_to_remote to make an ajax call. 2.3.8 Ajax call <%= link_to_remote image_tag("../images/services_button.jpg", :mouseover => "../images/services_button_over.jpg"), :url =>{:controller => :dashboard, :action => :service} %> Current View - <% link_to_remote view_path do %> About Us<s...

problem in configuring Apache as front server with mongrel

Hi all, i have rails application named src and am running mongrel as server to handle all request ,now am looking to configure APACHE as front end server, so i made some changes to http.conf file like this ServerName src DocumentRoot C:/InstantRails-2.0-win/rails_apps/src/public/ ProxyPass /src/ http://localhost:3000/ Proxy...

What requirments are necessary for a webhoster to host Diaspora*

What do I need to get from a webhoster if I want to host my own Diaspora* seed? Do I just need some webspace with ruby on rails capabilities? I suppose it uses Ruby On Rails SOAP for communication between seeds? If so what is needed for this? ...

Rails Paperclip 'class methods' and validations refactor ?

Hi, I've been breaking the DRY principle a bit in a project built with Paperclip for media storage. I've added assets to certain models, such as AlbumPhotoFile, AlbumSoundFile and so on, using the following code : # Asset is a regular < ActiveRecord::Base class class AlbumPhotoFile < Asset has_attached_file :pic, :url => "foo", :pat...

How do I add a partial's current folder to the rails view path?

I have a set of partials that are used to update a section of a form depending on the user's choice from a drop-down menu. There are a lot of different choices, so rather than having a view folder like this: app/views/myview/ _choice001.html.erb _choice002.html.erb ... _choice998.html.erb _choice999.html.erb _form.html.erb ...

How to add existing named_scope to anonymous scope?

Hi, I have a model: class Shirt < ActiveRecord::Base named_scope :red, :conditions => { :color => 'red' } named_scope :blue, :conditions => { :color => 'blue' } named_scope :xl, :conditions => { :size => 'xl' } end I forgot, how to easy add named scope to existing anonymous scope: scope = Shirt.scoped({}) #and how to add ie...

Rails 3 with mysql problem

Hello, I have updated to rails 3 on my Snow leopard. Previously i use sqlite for development. It's working fine when i rake db:create. Now I'm trying to install mysql on my mac. I downloaded mysql-5.1.50-osx10.6-x86.dmg Installed all three file.(mysql-{version}-osx10.5-x86.pkg, MySQL.prefPane, MySQLStartupItem.pkg) execute this to in...

Ruby Syntax: How to write "a = h[:v] if !h[:v].nil?"

I find myself often writing statements equivalent to: deleted_at = Time.at(data[:deleted_at]) if !data[:deleted_at].nil? i'd like to be able to write this in a more concise way. Any suggestions? Sometimes I write this as: deleted_at = Time.at(i) if !(i = data[:deleted_at]).nil? But I think this makes the code harder to read so I...

rails check for existing instance attribute

Hi guys I'm working on a social networking site (basically a copy of facebook to be honest...) and I reused big parts of insoshi. But the feed of insoshi is not accurate enough for my likings. As in it doesnt support more specialized messages. You will see what I mean in the following code: item = activity.item relationship = relation...

invalid content-Length ERROR while uploading 2 GB of stream

Hi all, When Trying to upload 2GB of stream i got invalid content length error am running Apache as frontend server to mongrel and chrome as my browser. One more thing one i do it with mongrel alone am able to upload this 2 GB of stream ,cud anybody tell me whats the problem and how do i configure content length in apache?? ...

Active item menu RoR

Hello. How I can get active item menu? Menu generate in cycle <ul id="menu"> <% for page in Page.roots %> <li><%= link_to h(page.name), page %></li> <% end %> </ul> I want use other css property for this item. Any ideas? Preferably js, jquery... ...

No eager loading when rendering anything else than :action => "index"

Using Rails 2.3.8 I've experienced the following problem. Eager loading works fine When I have a controller like this: def alternativeview @books = Book.all :include => :author respond_to do |format| format.html { render :action => "index" } end end However, if I want to render this action with a different html....

problem in routes

hi... i want to change the default route in RoR to what i want: consider the following example... :controller/:action/:id which will give you the route in the browser as: http://localhost:3000/controller/action/id now i want to change it to... http://localhost:3000/this-is-what-i-want/id we can get an alias for the controller and ...

Attributes don't work as expected in callbacks

This one catches me out a lot. class Repository < ActiveRecord::Base has_one :database, :storage before_create :provision_database, :provision_storage def provision_database self.database = Database.new # works end def provision_storage storage = Storage.new # doesn't work end end class Database < ActiveRecord::Ba...

How do I redirect to a specific action in a different controller in Rails 3?

I'm writing an API; in this API, I have a FruitBasket model which has Fruits. A particular Fruit may belong to more than one FruitBasket at a time. FruitBasket and Fruit are both ActiveRecord objects. If someone performs a GET on /fruit/100/baskets, I want to provide a JSON list of baskets which have that fruit, in the form of basket ID...

Resolving a class name conflict in a Rails application

I have been building a Rails application that performs accounting functionality. As part of this, I have a model with the class name Transaction. So far so good, I have been building this functionality for a month or so, and everything is working as expected. Until now... I have just discovered some older reporting functionality that w...

Are subsequent requests in Rails processed in the same thread?

For example if I assign Thread.current[:user] in the beginning of some requests, do I have to clean it up at the end of those request? Is this different between different versions of Rails or different server software such as Passenger, Mongrel and JRuby + Glassfish? ...