ruby-on-rails

How to render view template by jQuery in Rails

I need to render view template by jQuery. I have template 'category.html.erb' and file 'category.js.erb' with following code: $("#block").html("<%= escape_javascript(render :template => 'category') %>"); but it doesn't render category view template. Please help me! ...

Error installing memcached gem on Snow Leopard - wrong architecture?

I'm having an issue installing the memcached ruby gem on my Mac Pro machine with OS X Snow Leopard (10.6.4). Memcache is installed and working fine and for most projects I use the memcache-client gem without issue, but this current project I need to use the memcached gem instead. Installing the gem with env ARCHFLAGS='-arch x86_64' gem...

How to make optional :conditions for a find

Hello I have the followong struggle in my head. I want a text-field in which the use can type in some parameters, which will be used as filter-criteria for the :conditions hash in my find method. I have created a helper, with takes an option and merge the hash to the options: In my controller: @bills = adminbill_filter(:limit=>params[...

render :action with params

hello, I have one Class with 2 methods. The first method is called by the view with some GET parameters ( params[:page] ). I would like to save those params and send them by a render action to my second method. class exemple def first ## sql save of params[:page] render :action => "second" end def second ## ## H...

How to isolate/retrieve/count a subset of returned records in Rails

Hello all. I'm writing a reports dashboard for a rails app. The dashboard is for user data, and currently it's running multiple count an select queries to build the four or five reports on the page. I'm sure that there is a more efficient way to do this. How would I go about structuring the controller method so that it only runs one ...

Ruby on Rails: Plugins/gems for converting a .xls file to a .pdf file?

Hi, what are the Rails plugin/gem solutions for converting a .xls file into a .pdf file? Thanks a lot for any feedback! Tom ...

Where and how to handle rails exceptions?

I am currently involved in the development of a large rails application that interfaces with another product via a custom API gem. This has led to a very strange sort of error catching. For instance, when we interact with the other product, it might return an authentication error, which we expect. We then catch that error in our API g...

Rails update to version 2.3.8, error :undefined method `html_safe!' with simple_form helper

Hi, I've just updated my Rails gem version from 2.3.5 to 2.3.8 I'm using simple_form v=1.0 When I try to render a form I have an error message : undefined method `html_safe!' for # Can I patch it in my app or maybe it must be fixed in the simple_form version 1.0 ? Thanks for your advices :-) Fro_oo ...

Should I create a Ruby gem or plugin

I have some logic code that is literally cut and pasted across several different sites I own (it's code that interacts with a web API I've created). Considering that this isn't DRY and that when I update one thing I want it to update across all my sites I wanted to move this to a gem or a plugin. My main question is which one is the be...

Silencing cucumber stack trace

Does anybody know how to silence or filter lines from the backtrace of a cucumber run? Im running a rails 2.3.5 App with the database_cleaner plugin set to truncate after each scenario. And every time one runs, the terminal gets flooded with useless "NOTICE truncate cascades.. blah blah" message. I've tried using the config/initializers...

Creating AR model for Drupal database

how do I change my activerecord model default behavior for the find method? For example, i want to search for all books inside drupal nodes database, but drupal uses only one table for all data, and uses the 'type' column to find out the type class Book < ActiveRecord::Base set_table_name 'node' def find(*args) :conditions => {...

paginate_by_sql and Rails3.0.0Beta4

I am trying to port an existing rails app running rails 2.3.8 to 3.0.0beta4. I currently use this paginate_by_sql hack module ActiveRecord class Base def self.find_by_sql_with_limit(sql, offset, limit) sql = sanitize_sql(sql) add_limit!(sql, {:limit => limit, :offset => offset}) fi...

Validate presence of nested attributes

How do I validate that a model has at least one associated model using nested attributes? This has been driving me crazy as I am sure that I am missing something simple. For example, I want to require that a List always has at least one Task. class List < ActiveRecord::Base has_many :tasks, :dependent => :destroy accepts_nested_at...

Installing Rails ERROR on Windows XP: could not find rails locally or in a repository

I see a similar question here. However, that is related to installing on non-windows platform. I followed the instructions here and get error when I execute the following:- gem install rails The error is following:- ERROR: http://gems.rubyforge.org/ does not appear to be a repository ERROR: could not find gem rails locally or in a ...

Rails, AJAX, and jQuery..just add water?

Excuse my daftness, but I can not understand how ruby vars can be attained with jQuery. I made a button that by json POSTS to the server to make a credit_status = 0. But I would like that 0 to also auto-update on the page as well. My View: HQ $ = organization.total_credit = link_to 'redeem', redeem_admin_organization_path(organization)...

rails: convert a string with regex and write to database

I have an application that accepts an address and writes it to the db. I then want to take that address and convert it to something I can send through Google Maps, so I need to replace all the spaces with "+" symbols. I understand how to do that with a regex: address.gsub(/\s/, "+") And can create a variable that does it, voila. But I...

Execute SQL query from Rails when connecting to SQL Server 2005 through activerecord-sqlserver-adapter

So I'm connecting to SQL Server 2005 from my Rails app via the activerecord-sqlserver-adapter. I'm able to execute stored procs by doing Mymodel.execute_procedure("thisProcedure", param1, param2) But I have a stored proc that has a SQL INOUT variable that I'm having trouble with. I execute it, and I'm not seeing that variable returne...

how to put embedded document into an embedded document ?

hi I have a form that has a category model and and embeded docuement called "FieldModule" and this has embedded document called "SubFieldModule" For example class Category include MongoMapper::Document key :name, String many :field_modules end class FieldModule include MongoMapper::EmbeddedDocument key :name, String ...

Weird problem with Rails app and Mongrel

I originally posted a question relating to this problem on serverfault.com: http://serverfault.com/questions/152587/apache-mod-proxy-to-another-server I have since realized that this is not an issue with my server setup, but my rails application. I have set this application up server-wise the exact same as another functioning rails app ...

In Rails, how can I retrieve the object on a belongs_to association, without going through the database?

Consider the following setup: class Parent < ActiveRecord::Base has_many :children end class Child < ActiveRecord::Base belongs_to :parent end And this console session: >> p = Parent.find 41 >> p.some_attr = 'some_value' >> c = p.children.build >> c.parent By watching my log files, I can see that c.parent is querying the db fo...