ruby-on-rails

Can the Sequel Gem connect to MySQL over SSL

Hi Does anyone have any information on how to connect from the sequel gem to a remote mysql database over ssl? I can connect without ssl but trying to connect as a user who requires ssl just fails with the error message: Sequel::DatabaseConnectionError: Mysql::Error Access denied for user 'ssl_user'@'<IP_ADDRESS>' (using password: YES...

link_to_if Why does it show the Link Title if false?

Why does link_to_if show the link title if the condition is false? I'm using it on a DELETE, and if the condition is false, Rails shows delete but it isn't linked. I don't want DELETE to show up if it's false. Is there a setting or another helper for that? Thank you ...

Rails and Ajax form submission

I am writing an application that will allow a user to add a component to a particular page in my DB, but am stuck on a little bit of the JS. I have the form submitting just fine. I am stuck on how to "refresh" the container div that shows all of the current components tied to a page. I am from a PHP background, so I know that I could w...

Creating a form with a duplicatable nested form inside of it :: A Complex Form Question

I am making a self duplicating form. It can create multiple instances of itself. The hiearchy is, an Organization has_many Referrals. There should be no 'updating'. It should be only a 'create'. My error is : Unknown action No action responded to update. Actions: create and new My Form: - form_for @organization, :url => organizat...

Rails passing @variable from one show page to another

I have a Gallery application that has Album and Photo models. I have the user search in the Album's show view (search in the specific album) and I store the results in a variable named @search in the show action of the controller. I want to pass this variable to the Photo model's show page so when a user clicked on a particular pictur...

dynamically generate an attribute on an object, ruby, rails

Given these params: ex: 1 {:field => 'admin', :id => "1"} ex: 2 {:field => 'client', :id => "1"} ex: 3 {:field => 'partner', :id => "1"} Is it possible, (and how of course) could i dynamically apply this to the User model such as: controller #note the field attribute is not a field #the field attribute I'm trying to set above...

How to avoid ActiveRecord::RecordNotFound exceptions when querying multiple records

I have this code: Article.find([1,2,3]) But only record 1 and 2 exist in the database. I get this exception: "ActiveRecord::RecordNotFound (Couldn't find all Offers with IDs (1,2,3) (found 2 results, but was looking for 3))" Is there a way to only get the existing records and not the exception? ...

Newbie Question:Have to type localhost/controller/index in browser to get index method to display in Rails. Why?

I am new to Rails and I am reading Sitepoint's Simply Rails 2 but I am using Rails 3.0.0. In the book we had just set up our first controller (StoriesController) and fired up the server and typed in http://localhost:3000/stories and it should have displayed the index.html.erb file but instead when I type in that url I get "Routing Error:...

explicit require in Rails 3

I am converting my Rails 2 app to Rails 3. So far, I've been successful. However, there is this strange issue that I have to explicitly require any external files. Here is my original (i.e. Rails 2) ActiveRecord model: class Book < ActiveRecord::Base belongs_to :author has_many :translations, :dependent => :destroy include Freebas...

Java .NET vs PHP Rails

What are the benefits of using a compiled solution like .NET of Java over an interpreted solution like PHP or Ruby for building a Web Application/Web Site. It seems like Java or .NET apps would require a lot more overhead compared to a PHP/Rails solution. ...

Jqgrid and belongs_to relationship

Is it possible to display a belongs_to relationship in a single jqgrid? Example: Vehicle belongs to Person I can display the Vehicle jqgrid listing the person_id, but I would like to display the Person's name instead of their id. Example: person_id|vehicle_type 1 | honda person_name|vehicle_type Tom | honda ...

Rails 3 Routing Question

Why in Rails 3 do you have to uncomment match ':controller(/:action(/:id(.:format)))' (as seen in this Hello World article) to make the index method of the hello controller be called when you go to http://localhost:3000/hello? Can somebody please explain why we have to do this in Rails 3 but not Rails 2, and is this a normal thing for Ra...

Rails doing a FIND with Conditions?

Hello, In Rails 3, I created a Search Form that does a FIND with conditions in the Models file. @projects = find(:all, :select => 'projects.*', :conditions => ['name = ?', search_name] ).first This works great if a name is provided in the searchform (search_name). Problem is if searc...

How to pass parameteres to liquid methods?

I would like to pass collection of photos to the template and allow the user to select which picture she wants to display. What would be resonable implementation to do this? The best way to select a picture would be by ID, but the user can only access his own pictures in this scenario. Is the custom tag the only way to do this sort of th...

Difficulty with send_data in Ruby on Rails in conjunction with Spreadsheet plug-in

I have a function in a controller that takes in some specifications and generates a report on them. This function user_report is called in a view: < %= submit_to_remote 'submit-button', "Export Report to Excel", :url => { :controller => :reports, :action => :user_report, :print_state => 'print'} % > In reports_controller I use the Spr...

Rails problems with Join search. Please help!

Hello, I am developing a small user application in Rails 3 and is stuck on a search feature. I got a table called Profile which holds Firstname and Lastname. When searching this table I use: Profile.find_all_by_firstname(params[:keyword]) The thing is that I want the user to be able to search a table that holds contacts (profile_id a...

default_scope and associations

Suppose I have a Post model, and a Comment model. Using a common pattern, Post has_many Comments. If Comment has a default_scope set: default_scope where("deleted_at IS NULL") How do I easily retrieve ALL comments on a post, regardless of scope? This produces invalid results: Post.first.comments.unscoped Which generates the follow...

Is it possible to step through a RoR application? or only debug using the debugging breakpoint?

I read that you can put a 'debugging' symbol in your RoR code, and then execution will Halt at that point and then you can then spit out anything into console to see the state of variables etc. Is there a way to step though each line and follow the execution path? ...

How does using updated_at in your memcached key avoid DB hits?

While reading up on caching options for Rails, I've just watched the Scaling Rails episode on memcached, where they advocate using the updated_at field of a record as part of the cache key. This is supposed to ensure that when a cache block contains the contents of a record, whenever that record gets updated, it will invalidate that cach...

Ruby on Rails' "controller.helper" is missing, how to solve it?

If a project is running Rails 2.2.2, and it uses controller.helper and the helper is not defined, then how can it be solved? (this is for the Facebooker2 gem http://github.com/mmangino/facebooker2) details: error shown: => Rails 2.2.2 application starting on http://0.0.0.0:3000 Exiting /Library/ Ruby/ Gems/1.8/gems/facebooker2-...