ruby-on-rails

Browsing Image in rails App on Apache Server

Hi All, My rails application is running on Apache server with phusion_passenger gem. For testing purpose I used both attachment_fu and paperclip to upload image in that application. There are two different methods, one for image uploading using attachment_fu and another for paperclip. When the application starts in development mode, ev...

Is Twitter still running on Rails?

I know Twitter initially ran on the Ruby on Rails platform. Is this true today? ...

factory_girl has_many :through with validations

I have the following models: class Activity < ActiveRecord::Base has_many :clientships, :dependent => :destroy has_many :clients, :through => :clientships end class Clientship < ActiveRecord::Base belongs_to :client belongs_to :activity validates_presence_of :client_id validates_presence_of :activity_id, :unless => :ne...

Connecting Tables in Rails

Table City Model class TableCity < ActiveRecord::Base has_many :near_cities, :foreign_key => "nearcity_id" end NearCity Model class NearCity < ActiveRecord::Base belongs_to :table_city end Controller @table_cities = TableCity.find(:all, :conditions=>{:state => params[:gm], :language => params[:sp]}, :include => :near_cities)...

"uninitialized constant XmlSimple::Zlib" in ROR xml parsing

Hi i am using gem 'xml-simple' to parse the xml data in Ruby on rails, but i am getting error called "uninitialized constant XmlSimple::Zlib". Can any body tell what the error is? ...

Rails form in external site with ajax

Basically I'm wondering if it's possible to have a form on a site outside of mail Rails app to POST to a form in my Rails app. For example (not what I'm going to be doing) a contact form on a Wordpress site, when submitted would POST the values to my Rails app. What would my steps be to make that possible? Or any references that are alre...

Where can I use cookies in Ruby on Rails

I'm using controller's initializer to setup stuff that I will need. def initialize super() a = cookies[:a] # EXCEPTION end However I can't use cookies because it's null, the system hasn't read them from the header yet. The same problem was with ASP.NET MVC, where I couldn't access the cookies in the constructor, but I could acce...

failed to allocate memory

Hi all, Am running apache as frontend to mongrel ,i am passing request to mongrel using passproxy like ProxyPass / http://localhost:3000/ i have download routine in one of controller and now i would like Apache to server this request...for that i put a line in httpd.conf ProxyPass /streams/download/6626/ ! now my request fo...

How do I add file uploads to a rails app?

I need to add the ability to upload and store any kind of file, PDF, XLS, DOC, etc. What is the best way to do this in a ruby on rails application? ...

Track weekly changes a.k.a trends (db design)

I have a site where people can add their favorite TV shows. I would like to have some trends statistics. Example: (1 unchanged) The Big Bang Theory (3rd last week) How I Met Your Mother (2nd last week) House (30th last week, up 400%) Nikita I'm not sure how to design the database for this, but here is my idea: Once a week, I run ...

How to avoid Rails scaffold to place model into namespace

Hi guys, Rails 3 scaffold generator places model classes inside namespace. Example: rails generate scaffold admin/portfolio But I want only controllers and views to be placed inside admin namespace. How can I avoid that? Regards, Alexey Zakharov. ...

Do I need to use an asset packager with Ruby on Rails?

I am researching asset packager gems for Rails. I found out that Rails has its native solution to this problem in the cache=>"all" option on the include tag helpers. There is also some discussion about whether this is good enough, and some gems like Jammit have their diehard defenders. If there is a native solution to packaging javascrip...

Does creating more mongrel clusters improves application performance/response?

Hi I have currently 10 instances of mongrel cluster running. But at rush hour my avg response time goes up. See bellow Average db time 0.00 sec Average request length 24.92 sec Average view time 24.73 sec Requests 8.10 req/min Slow Requests 5.40 req/min Slow requests percentage 67% HOw can I improve avg response time? How...

strange rails routing and ActionView::Template problem

I have following in my routes.rb: namespace "admin" do resources :categories end resources :categories and all works well. However, as I remove or comment out: "resources :categories" part namespace "admin" do resources :categories end #resources :categories I am getting: ActionView::Template::Error (undefined method `cat...

What components make VIM a good (great) ruby editor?

I'm learning ruby on rails on a linux box and dusting off my VIM skills (skillz?). When I got started on VIM way back in my c++ days, I had a friend with a great vimfiles folder that had tons of stuff to get started. Starting from scratch, vim is great, but it feels like it could be a lot better. I currently have: vim-ruby buffer ...

Error patterns in rails, raise "text evaluting to RuntimeError" or raise MyModule::CustomError?

Q: The title is perhaps too big of question and the answer probably is "it depends"? However, providing some practical cases/examples should help developers, like myself, recognize when to apply what. I'll start out with my particular situation. Would you or would you not use custom error classes? Why/why not? Other examples as the one...

Feather an image from code

Is there any way to feather an image from code? (If you don't know what feathering is, check this out - I'm not using dirty language) I know professional design applications like Photoshop can do this, but I would for users to upload images to my site and then display them in a feathered fashion. (Now there's a sentence you don't hear...

does flash use sessions?

when you use the flash object to pass a message to the next view, does it use sessions for this? i.e. in a multi-server environment, this will cause issues ...

Attaching conditional methods(or attributes?) to a rails model

I'm using the friendly_id plugin to generate SEO-friendly URLS for some of my models. Currently, I have a model with two attributes: name and display_name. Essentially, display_name is preferred, but if it is blank, the model reverts to name. Friendly_id needs a field to base the URL off of: Class Market < ActiveRecord::Base has_fr...

How to do URL rewrite in Rails?

I have a rails app that is accessible through multiple URLs, I was wondering what is the best way to rewrite the URL to use the main domain name, abc.com. I have a bunch of other domain names like 1kjsdf.info 2lksjdfs.info 3sldkjfds.info ... in total 50 of these kinds of domains. They all end in info if that makes it easier. I used lig...