ruby-on-rails

Rails Rendering Action in Different Controller

So I have a controller called Music with one action which is index. On the music/index.html page I list out a bunch of Songs (via a Song model) and at the bottom I have a for to create a new Song. Song has validations which I have tested and work just fine. When the new Song saves in controller Songs action create I redirect_to => 'musi...

Change a Rails App to production

How can I change my RoR app to run in production mode? Is there a config file (environment.rb for example) to do that? Thank you. ...

Web site aggregation with twitter widget SSL issue

Hello! I'm seeking for solution how to isolate widget included by partial to main site. Issue appear when user access site with https. Ie 6,7 shows security confirmation dialog (part of website resources are not in secure zone). First of all I download twitter widget on our side, also I download all CSS and pictures. Then I patched widg...

Rails Nested Model Form with has_many through Relationship and build call

I'm building a one page form that will create a model and it's relations. I've gone through a ton of resources around the net as well as the complex forms series on Railscasts but can't seem to find the solution to my problem. Here's what I have. class Campaign < ActiveRecord::Base has_many :artwork_groups has_many :artwork_locales...

Finding unused images in a Rails app?

I'm familiar with tools like Deadweight for finding CSS not in use in your Rails app, but does anything exist for images? I'm sitting in a project with a massive directory of assets from working with a variety of designers and I'm trying to trim the fat in this project. It's especially a pain when moving assets to our CDN. Any thought...

Home_path issue with RoR testing locally on mobile device

When I use <%= link_to image_tag("foo.png"), home_path %> and display it on my localhost on my iPhone, it's broken. When I inspect on with firebug, the src of the image is http://localhost:3000/images/foo.png thus causing it to break on my iPhone. When I use <img src="/images/foo.png" /> it displays fine on my iPhone. I am point...

Can the Friendly ORM be used alongside a traditional database schema?

Can I use ActiveRecord for existing models and Friendly for new models? Basically, I want to decide which models I'd like to be schemaless and which models I'd like to be done the "old" style. ...

Is learning Java and related technologies worth it today?

My career has always been C and C++ programming. I have some basic Java experience. I have a lot of personal Ruby/Rails experience and lately I've been doing some Grails stuff at work as well. I'm just curious if it's worth it to pick up Java and related technologies such as Spring, Hibernate, etc... Grails seems like it removes the n...

ActiveRecord derived attribute persistence which depends on id value

How do you persist a derived attribute which depends on the value of id in rails? The snippet below seems to work-- Is there a better rails way? class Model < ActiveRecord::Base .... def save super #derived_attr column exists in DB self.derived_attr = compute_attr(self.id) super end end ...

Single entry web apps in Rails

Can someone please point to some docs or links which show how to create a single entry point ( similar to CMS like Joomla ) web app in Rails. I need to create a web app in Rails where there will a lot of places which will have restricted access based on whether the logged in user has paid for that functionality. ...

Calling a rails function from javascript

Hey all I'd like to trigger an action from my rails controller when the user leaves a page. I fell onto the window.beforeunload event, but I don't know how I can call the function from my controller from the view. I have something like this: //function that checks if someone leaves the page //if so, send mail to admin with uncon...

Capistrano and Git, Ruining my life. "Unable to resolve revision for [HEAD] on repository ..."

Hey All, I searched all of the relevant Capistrano issues, but couldn't find something that even elucidated anything here for me. git version 1.6.4.2 Capistrano v2.5.10 Basically, when I run my cap deploy.rb script, it connects to the server, starts executing the deploy:update task, then in the deploy:update_code task: *** [...

Explicit return from a Ruby method - implementation hiding, reuse and optimisations.

Hi, Rather than allowing a Ruby method to blindly return the last statement evaluated, is there any advantage to returning nil explicitly? In terms of implementation hiding and reuse, it seems dangerous to blindly allow the last expression evaluated to be returned - isn't there a danger that a user will rely on this only to get a nast...

Rails: New migration but nil in controller

Hello! I have created a new migration: class AddSignatureToUser < ActiveRecord::Migration def self.up add_column :users, :signature, :text end def self.down remove_column :users, :signature end end Now my usertable has a new column called signature. On my edit page I wrote: <h1>Editing user</h1> <% form_for(@user) do...

Is it possible to change the logging level of delayed_job separately from the main Rails app?

I'd like to use the DEBUG logging level for my Rails app on our staging server, but I'd like delayed_job (which logs a SELECT statement to the main Rails log every 10 seconds) to log at INFO level, so I don't get these delayed_job SELECT statements in there. Is this possible? ...

Floating div in rails

When the user clicks on a link, I want to open a modal window (like the ones used in stack overflow, but centered). If the browser doesn't allow to open floating div, then go to another page. Is there an easy way to do this in Rails? (otherwise I can code it from scratch) ...

Snow Leopard upgrade -> reinstalling sqlite3-ruby gem problem

Hi all, I got ruby 1.8.7 (native compiled), rails 2.3.4, OSX 10.6.2 and also sqlite3-ruby. The error I'm getting when accessing the rails app is NameError: uninitialized constant SQLite3::Driver::Native::Driver::API History: I upgraded to snow leopard by migrating my apps with a FW-cable from my old macbook to the new one. Everyth...

Using Stored Procedures in Rails

As I said in a previous post, our Rails app has to interface with an E-A-V type of table in a third-party application that we're pulling data from. I had created a View to make the data normal but it is taking way too long to run. We had one of our offshore PHP developers create a stored procedure to help speed it up. Now we run into ...

Paperclip problem

Hi I have the video upload applicaton. I am using thoughbot paperclip plugin for uploading video files and i convert the video files into "flv" format by using ffmpeg . The problem is the users can also upload the "flv" video files, in this case the browser keeping of waiting, the bottom of the browser its shows "sending request to...

Anybody has luck running Rails application on Weblogic using JRuby?

My application is developed on Rails 2.3.5, its running fine on Webrick, Mongrel, Tomcat and Glassfish. But when I try to the run the same war file that was generated using warbler gem in Weblogic, I am getting the following error: Application initialization failed: no such file to load -- rack from C:/bea/wlserver_10.3/samples/domai...