ruby-on-rails

Using 2dc_jqgrid, how do I display customized data?

I am using jqgrid with Ruby on Rails using the 2dc_jqgrid plugin -- 2dc_jqgrid details). By default, the plugin seems to take information directly from the fields in your model and display them in the resulting table. For instance: books = Book.find(:all) do if params[:_search] == "true" id =~ "%#{params[:id]}%" if params[:id].p...

Render cached action of another controller inside erb template

Hi, I want to render action inside my erb template. <div> <%= render :controller => :tags, :action => :tag_cloud %> </div> This block throws exception: undefined method `formats' for nil:NilClass Also I want to tag_cloud action to be rendered from cache. Is that possible? Regards, Alexey Zakhaov ...

Where to put Global variables in Rails 3

I used to put Global variables in environment.rb with my Rails 2.3.8 application such as: MAX_ALLOWD_ITEMS = 6 It doesn't seem to work in Rails 3. I tried putting it in application.rb and that didn't help. What do you suggest? ...

Template path in Rails 3

Let's say, I connected the route / to WelcomeController's index action. Inside of the index.html.erb-Template I want to display the path of the template from Rails.root upwards, ie. <h1> We are rendering: <%= how_do_i_do_this? %></h1> to render to <h1> We are rendering: app/views/presentation/index.html.erb</h1> In Rails 2 I cou...

What do I need to know about JRuby on Rails after developing RoR Apps?

I have done a few projects using Ruby on Rails. I am going to use JRuby on Rails and hosting it on GAE. In that case what are the stuff that I need to know while developing JRuby apps. I read that JRuby has the same syntax I can access Java libraries JRuby does not have access to some gems/plugins JRuby app would take some time to load...

Ruby String to Date Conversion

Hi, I am faced with an issue in Ruby on Rails. I am looking to convert a string of format Tue, 10 Aug 2010 01:20:19 -0400 (EDT) to a date object. Is there anyway i could do this. Here is what I've looked and tried at the following with no luck: Date.strptime(updated,"%a, %d %m %Y %H:%M:%S %Z") Chronic Parser Ruby: convert string to ...

ActiveRecord has_one relationship alongside a has_many relationship

I'm struggling to model a particular relationship with ActiveRecord. I currently have the following setup and working class Schedule < ActiveRecord::Base has_many :tasks end class Task < ActiveRecord:Base belongs_to :schedule end with a database structure that looks like this: schedules - integer:id tasks - integer:id ...

Cleaner way to do this in Rails

Hi, I have some code in one of my views like this. I feel that it has too many if else conditions. All it does is checking for the ActiveRecord Object's status and setting the image. Is there a better way to do the following in Rails? <td class="notification_msg"> <% if notification.status == NOTIFICATION_STATUS.index("Failure") %> ...

Is it worth to start learning rails 2 or should i wait until books on rails 3 are available?

I had always dreamed about learning rails and the ruby language, but there seems to be a big change comming with the new rails 3 release. So are there generally huge differences between 2 and 3? Should i probably start with rails 3 when books are available since this is the way i learn the best? ...

Disable SQL Cache temporary in Rails?

Hello, I'm currently creating a Rails app with some cronjobs etc, but I have some problems because the sql is cached by Rails. So anyone know how to disable the SQL Cache in Rails? Not globally, but for this code. Really don't want to create one method for every model, so is there anyway to just disable it temporary? Terw ...

How do I offer a beta feature to select users? (rails)

We want to start letting our users help us test our feature changes before a wider release. Our rails app already has roles but I don't know how to we should go about implementing a beta feature without moving the whole app over. Some issues I can't think of solutions to: A beta feature may require a database migration. How can yo...

parameters sql query in find by sql

How to pass parameters sql query in find by sql ...

Custom Rails Validation - multiple fields simultaneously

I'm looking to create a custom validation in Rails. I need to validate that a POSTed start_date_time and end_date_time (together) do not overlap that combination in the database. Example: In the database: start_date 05/15/2000 end_date 05/30/2000 POSTed: start_date 05/10/2000 end_date 05/20/2000 FAILS! Here's the rub: ...

Rails: How to create databse schema with ActiveRecord::Schema like in django?

I like Rails, but I'm not a big fan of migrations. How can I use the ActiveRecord::Scema tool to create a database without using SQL and without migrations? I know you use it like this: ActiveRecord::Schema.define do create_table :authors do |t| t.string :name, :null => false end add_index :authors, :name, :unique...

how to make f.text_field+"<div>there is a error</div>" work

I write a helper method in applicationhelper something like this str = f.text_field(:username) + "<div class='error'>username is wrong </div>" then in my view.rhtml it shows like this <input type="text" value="" size="30" name="user[username]" id="user_username"> &lt;div class="errors"&gt;username is wrong&lt;/div&gt; an...

Can I redirect_to a javascript request to another javascript action?

I have a comments controller with index and create actions among others. Both those actions respond to html and js format. Whenever I got create request via ajax, I would like to add new comment and then redirect to index.js, so the comments on screen are updated without reloading the page. This sort of thing works flawlesly in Chrome...

How to embed videos using TinyMCE

I'm working on Ruby on Rails 2.3.8 and I've installed TinyMCE (last version). For a start, it displays correctly on my website, but I found out it cannot show embedded videos. So, I googled for this, but no luck. Does anybody knows how to accomplish this? ...

Rails 2.3.8 not displaying stack trace in browser, instead shows 500.html

Hi, stack trace is not showing like it should (in the browser). Instead I get public/500.html rendered. The problem seems to be recreated when I created a new rails project and apply the haml plugin. Originally I though it was this ruby script causing the problem: class ToHaml def initialize(path) @path = path end def convert...

Authlogic can't find user

I am integrating facebook connect with my application which uses authlogic, facebooker, and the authlogic_facebook_connect plugin. After I log in with facebook, I get redirected to the front page of the site (as per my code) - but the page never loads! - it hangs. Looking at the development log, I see that something is continuously tryin...

how to fetch hierarchy of my model in rails.

This is my common model which has no table. class CommonActiveRecord < ActiveRecord::Base self.abstract_class = true def before_validation set_blank_attributes_to_nil(@attributes) end end My other models look like this .. class BalanceName < CommonActiveRecord def before_validation super end end I want to fet...