ruby-on-rails

Rails/Ruby delete_if

I have a select tag nested in my form and I am needing to delete an item from my options_for_select array if it equals the word English code: <%= fields_for :users_languages do |u| %> <div class="field"> <%= u.label :Assign_Languages %><br /> <%= select_tag :language_id, options_for_select(Language.all.collect {|lang| ...

Rails 3 Conditional Inclusion of Javascript files

I'm trying to figure out the best way to include the following in my head in rails 3: <!--[if IE]><script language="javascript" type="text/javascript" src="/javascripts/excanvas.min.js"></script><![endif]--> As you can see, I just want that javascript file availabe to IE... so perhaps I shouldn't do it this way at all... I'm open to ...

How to copy multiple row with single column update.

I want to copy all the rows from my table with single column update. Example. Table County has 1000 rows and i want to copy all the rows with single column update. What is the proper way to do that ? ...

Best Practice: Order of application design

I can think of quite a few components that need to be created when authoring a web application. I know it should probably be done incrementally, but I'd like to see what order you usually tackle these tasks in. Layout your usual order of events and some justification. A few possible components or sections I've thought of: Stories (i...

Multi-step form using GET requests

We have the unusual requirement of a multi-step form through GET requests. So, instead of POSTing the forms, we're using GET requests to pass new parameters to the query. So, the basic idea is that there's a treatment, and a date passed to the query. A three-step form if you will. Show available treatments, pick one Show available d...

Silverlight developer, learning ruby, rails

Hello! As said in title I'm SL developer and want to learn ruby and after adopt rails. Which books/resources/screencasts you can recomend to get up and running quickly? I'll use Linux and chosed Netbeans as IDE but if i won't like it i'll use gedit. What can you say about this? ...

rails scaffold errors.

I am getting the following error, when I follow the "New" link: equipment_url failed to generate from {:action=>"show", :controller=>"equipment"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["equipment", :id] - are they all satisfied...

Nokogiri XML Parsing with Rails

I looked at a lot of tuts but this one seems to have got me where I am controller def index require 'nokogiri' doc = Nokogiri::XML(open("http://sports.yahoo.com/top/rss.xml")) @links = doc.xpath('//item').map do |i| {'title' => i.xpath('title'), 'link' => i.xpath('link'), 'description' => i.xpath('description...

How can I cycle through a dynamic set of Active Record Models?

I have three Models (and growing): ContactEmail, ContactCall, ContactPostalcard I want to cycle through the three of them to go through a pretty lengthy loop. A sample would would be the following: import_event = ContactEmail.sugarcrm_is(false) #using searchlogic gem The second loop would be: import_event = ContactCall.sugarcrm_is(...

RVM vs MacPorts for managing RoR

Hello, I'm diving into Ruby on Rails and two tools were suggested to me right from the start, RVM and MacPorts. I'm using RVM at the moment to manage my ruby and rails installs, so MacPorts doesn't appear to offer me much that I don't already have. I certainly see the differences between the two, RVM is primarily used for Ruby installa...

Rails File Download And View Update - Howto?

Hi there, This seems like it should be straight-forward, but I'm stumped. I have a link to a view controller that ends up using send_data to download a file to the user's hard drive. This works very well, and it leaves the current view apparently untouched. But now I would like the page to provide some feedback after that download is c...

Are Rails project portable across various computers?

I'm currently developing a Rails project in my computer. I would Like to give a copy of project to my friend so that he can parallely work on the same project. Does copying the project directory to other system , help this ? Or should I do more to carry the project to different systems. ...

Can i pass method name as argument with super ?

I have created a common controller for my application. class CommonController < ApplicationController def index # My stuff end end And in my other controller i am using super to call my index method like this. class Other1Controller < CommonController def index super end end class Other2Controller < CommonController ...

Debugging Rails in Netbeans 6.9 suddenly stopped working

Hi, Yesterday I was perfectly able to debug a rails application using Netbeans 6.9.1 (just clicking on the Debug Main Project). But now, suddenly when I try to debug I see the "Server Startup" at the bottom... but after 30 secs aprox. a message appears in the status bar saying "Cannot connect to web server, cannot show localhost:3000"....

Rails 2.3.5 link_to generates path that "No route matches" when passed to recognize_path

There is a route: admin.resources :orders,:collection=>{:export=>:get},:member=>{:gener=>:get} In the console when I use link_to I get the following: >> helper.link_to "test", :controller=>"admin/orders", :action=>"gener", :id=>33, :format=>"pdf", :line=>412, :player=>393 => "<a href=\"/admin/ord...

Looking for a simple test for circular reference in a recursive model

I have a model that represents an assembly that is made up of components, components may (in their own right) also be assemblies. It looks a little like this: class Component < ActiveRecord::Base belongs_to :assembly, :class_name => "Component", :foreign_key => :assembly_id has_many :pieces, :class_name => "Component", :foreign_key...

Sharing rails connection polls between instances

I am running 10 rails instances via Phusion Passenger behind an nginx server. I see that rails can manage a database connection pool just by setting pool: 10 in the database.yml file. However, I don't need 10 connections per rails instance. Really, I just need 20 or 30 connections total to serve all 10 rails instances. Is there any w...

Rails database - how to store encrypted data using the user's password?

I have a database that will be holding sensitive data, so it should be encrypted in the database. Basically the sensitive data are credentials to another web site. So I want to encrypt them with the users password + salt. To decrypt the credentials one would need the password. I see two ways: On login, I could decrypt the credentials...

Accessing a RoR ActiveRecord's attributes from within the ActiveRecord instance

Hi, I am confused about how to access the attributes of an ActiveRecord instance from a method within the ActiveRecord instance. For example I have a Lead class that inherits from ActiveRecord: class Lead < ActiveRecord::Base end I have the following scaled down migration file that shows the columns of an ActiveRecord table: class ...

Rails 3 - AutoComplete with jQuery

Hello, I'm interested in using the Rails 3 AutoComplete plugin for jQuery but the one tutorial provided doesn't match my use case. Hoping for some help... Plug In: http://github.com/crowdint/rails3-jquery-autocomplete-app I have a Permissions Controller where people can add team members. On the Permissions SHOW view I want to show a a...