ruby-on-rails

How can I profile a request in rails?

How can I profile a controller action? One of my views is taking quite some time to render and I'd like to break it down. I see script/performance/profiler, but that seems to only have access to the global scope. ...

RMagick Rounded Corners

Need a simple a way of rounding off an Image. I need the corners to be transparent. This link shows how to do it via command line: http://www.imagemagick.org/Usage/thumbnails/#rounded What I need is the corresponding RMagick\Ruby code... Thanks! ...

How do I render a site out on my own domain with Ruby on Rails or anything?

This is what I'd like to achieve: User input URL (http://google.com for example) GET the page, and render it on my own domain Traverse the DOM (Using JS) and all that jazz The problem is I don't want to use an iFrame, because then I can't traverse the DOM of the page loaded. The only solutions I can think of is to parse the page for...

How to install mysql gem on Mac os 10.6 ?

i just installed MAMP on this iMac and the rubygems but when i run: sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config gives me Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Ver...

Authlogic - current_user or @current_user?

Hey, please help me to understand something. In Authlogic example in UsersController it's always used @current_user, so for instance: def show @user = @current_user end (taken from http://github.com/binarylogic/authlogic_example/blob/master/app/controllers/users_controller.rb) Why is that? In my controllers I use just current_user...

Ruby on Rails script/console printing more than expected

I have a simple model setup in my Ruby on Rails app. (User {name, username, lat, lon}) and am writing a basic extension to the model. I would like the method to return users within a certain distance. It all works just fine in the page view, but as I am debugging I would like to work through some testing using the script/console. My ...

ruby on rails adding new route

i have an RoR application Log, which similar to the book store app, my logs_controller has all default action: index, show, update, create, delete.. now i need to add new action :toCSV, i defined it in logs_controller, and add new route in the config/routes as: map.resources :logs, :collection => { :toCSV => :get }. from irb, i check...

Rails - Trying to query from a date range...everything from today

I'm trying to figure the best way to query a date range from rails...I looked around on Google but am unsure about how to use this syntax. I have a Model that has various events and I like to add to my find condition a caveat that should only show events where the field :st_date is today or later, in effect only show me data that is cur...

Rails 2.3.2: Accessing Model Specific Data in Another Model

I'm using Rails 2.3.2 and using Paperclip to upload photos. I'm also using a slightly customized subdomain_accounts.rb to set some account-specific variables. My question is this: How can I set the bucket used in Paperclip to be dependent on the current account? Since this looks to be a model attribute set up early on, how can I overri...

Recording Audio through RTMP/Rails

I am in the process of building a rails/flex application which requires audio to be recorded and then stored in our amazon s3 account. I have found no alternative to using some form of RTMP server for recording audio through flash, but our hosting environment will not allow us to install anything like FMS, Red5, etc. Is there any existi...

rails mysql BLOB type - to_xml returns binary, would like to force to string

I am running RoR, Ruby 1.8.6/Rails 2.3.2. I am persisting a String within a model object to MySQL to a Blob field. For a number of reasons, I have to use MySQL Blob data type instead of a Text data type, yet I want Rails to treat the field as a regular String (instead of a binary String - which is what I think it is doing?). How can I...

Modifying records in my migration throws an authlogic error

I'm adding some columns to one of my database tables, and then populating those columns: def self.up add_column :contacts, :business_id, :integer add_column :contacts, :business_type, :string Contact.reset_column_information Contact.all.each do |contact| contact.update_attributes(:business_id => contact.client_id, :business...

How does RoR's reloading content on refresh work?

RoR allows you to, as long as the env is development, change parts of the your application code and then just refresh the browser--and everything is changed, without having to restart Mongrel. How does this work, and where in the Rails codebase is this done? (Or, alternatively, is there some easy way to do this with Rack+Mongrel?) Tha...

How do I best run a search on Date when it is not a :has_many association?

I have a number of activities that have a calculated scheduled date. The activities, for example, Email, have a email.days method which is the days from a Contact.start_date on which it should be sent. This means contact.start_date + email.days yields a date on which email is sent to contact. I would like to use link_to around the dat...

Nested resources in namespace form_for

Problem The form_for helper incorrectly determines the path to my nested resource inside of a namespace. The models in question are: Forum::Thread and Forum::Reply respectively, located in a subfolder called "forum" under my models directory. This is in Rails 3 BETA 3. routes.rb namespace :forum do root :to => 'threads#index' ...

Why is my new ID always "1"

I have a parent-child relationship between two objects. Parent :has_many :children Child :belongs_to :parent When creating a new parent, in the same controller, I'm creating the child. @mom = Parent.new @child = Child.new @mom.children << @child That all seems to go okay, but this parent has one more attribute - this parent has a ...

composed_of in Rails - when to use it?

When should you use ActiveRecord's composed_of class method? ...

How to get link_to in Rails output an SEO friendly url?

Hi, My link_to tag is: <%= link_to("My test title",{:controller=>"search", :action=>"for-sale", :id=> listing.id, :title => listing.title, :search_term => search_term}) %> and produces this ugly URL: http://mysite.com/search/for-sale/12345?title=premium+ad+%2B+photo+%5Btest%5D How can I get link_to to generate: http://mysite.com/...

Sharing Models between two Rails Projects - using git submodules?

I have a Rails website which has been divided into two separate projects - the public site, and the administration site. As both sites are using the same database the models are shared between the applications (actually right now they are duplicated). The problem I have here is that when an update to the models occurs in the public proj...

Noob filter: How do I refer to a string that is passed to my Ruby on Rails method from Flex as a HTTPService?

EDIT: Got too confusing with so many different edits, so this is where I'm currently at. I have a HTTPService in my Flex 4 app defined as follows: <s:HTTPService id="getUserDetails" url="http://localhost:3000/users/getDetails" method="GET"/> I call this service like this (note: I've checked the network monitor in Flash Builder 4 and...