ruby-on-rails

Porting rails to java

I have a ruby on rails application and thinking about porting it to java. What are the things I should consider before that? How hard is that task in terms of changes required? Any advice from the people who have walked this path is greatly appreciated. Motivation: I have two web applications using same data. One is in java, another - ...

About a index of blog and show description and show all

i got a problem about blog making i need something like the site railcast which is before enter the title i will see the index page description with limited row after enter the title only see the full paragraph i failed to do in this way My index View :: <% for post in @posts %> <div class="blogPost"> <h2> <%= l...

Gearman architecture queries

Hey All, I am new to Gearman. I have following queries about optimized Gearman usages: 1) I think worker expects job as a "string". Can I send an Array or Hash as Job to worker? If not, is JSON the best Job format to send Array/Hash? 2) Can I attach rails application routes as worker for Job Server? 3) How do you check if a worker ...

LocalJumpError, Tag Cloud with acts_as_taggable on Rails 2.3.5

I'm using acts_as_taggable_on_steroids plugin with rails 2.3.5 to build a tag cloud and I'm unfamiliar with the syntax of their view loop. I couldn't find any ruby doc explaining that loop either. When I run the code below I get this "no block given" error. LocalJumpError in Tags#index Showing app/views/tags/index.html.erb where line ...

Rails custom routes question

I have an aplication that has an User and a Project model. I have the following relationships between those 2 models: USER has_many :authorships , :foreign_key => :author_id has_many :moderatorships, :foreign_key => :moderator_id has_many :authored_projects, :through => :authorships, :class_name => 'Project' has_many :moderated_projects...

how to put elements from model into select_tag

i have a database Country filled with (obvious) contries. now i would like to display them in the select_tag in my view (like a drop down list). i tried puttin in options_for_select sth like @show_me_the_countries_mama.each do |f| ('[' + f.printable_name + ']' + ','). this would list countries each one of them in [] brackets and with s...

redirect_to and :controller, :actions getting mixed up in Rails

In a Rails controller I'm calling this: redirect_to :controller => "user", :action => "login" My user_controller.rb defines the following method: class UserController < ApplicationController def login ### end When I call my redirect_to method I get this error in my browser: No action responded to show. Checking the server lo...

Using Rails' ActionView Helpers outside of Rails

What do I need to do to get number_to_human_size to work in a script outside of rails? ...

How to assign a value to an object depending on where the request came from

The application I am creating in RoR has a model (Practicetest) and its controller has the standard CRUD actions then an Sat & Act action. The Sat & Act actions are essentially the index of practicetests but if the test_format value is set to "sattest" then the test is displayed on the practicetest/sat view and if the test_format value i...

adding values to a select box from a controller function (Ruby on Rails)

I have a Rails web application with a select box: <%= select_tag :foo %> I'm looking to write a function in the controller which would populate this select box with some values. What code would I need to write in order to do that? It's fine if the values are hard coded into the function. def populate # what goes here? end ...

Approach to limit the visibility of data

Ok, suppose to have this db schema (relation): |User | (1-->n) |Customer | (1-->n) |Car | (1-->n) |Support | |--------| |---------| |-----| |-----------| |id | | user_id | |Brand| |Description| |username| |lastname | |PS | |Cost | |password| ...

Modify html of rails `link_to` helper

Rails has the link_to helper, and I'm aware that its output is determined by the ActionView::Helper::UrlHelper` method, but what is an easy and simple way to modify the behavior or rather make a different helper that would work similarly, the default behavior would output something similar to: <a href="/blah" class="my_link">go to blah<...

Controller pages inaccessible in new RoR project...why?

I set up a new RoR project on MAC OS Leopard, created a repository, svn added the whole Rails project, committed, checked out at my site, set up a vhost (see below), and I cannot get to a new controller page I created (/mycontroller/index). I CAN get to the "Welcome Aboard" page. I have another Ruby install (Redmine project management so...

routes.rb explicitly choose template

I would like to create one .erb file to be the output for a number of tiny actions that are just returning JSON. So with routes similar to: map.json 'contacts_json', :controller => 'contacts', :action => 'get_json' map.json 'cal_json', :controller => 'calendar', :action => 'get_json' ... but this requires I create a contacts erb, and...

Managing many Ruby on Rails applications of different versions

I'm learning Ruby on Rails with the AWDR book and have had to be specific about which version of Rails and Ruby that I am running on my local machine. I have just discovered that I need to roll back from ruby 1.8.7 to ruby 1.8.6 here. I also needed to roll back Rails to support the scaffold method so I could start the tutorial easily. ...

RJS or Javascript?

I've used RJS in the past for RoR projects and felt terribly constrained by what it could do. However, using Javascript alone felt/feels ugly and hack-y. This is particularly true when writing Javascript that manipulates Rails automagically generated from variable names. I haven't seen much talk about RJS in the blogosphere recently. Is ...

Java, Code Igniter, RoR, DJango web Application Challenge

Hi, This is a framework/programming language challenge. I'm looking for programming language that would be best approach for the next project. I want to get some score (out of 10) of their Time to Develop, Scalability, and Security. Form Builder that will read and write to Database(MYSQL) User Authentication and User Management Easy f...

Hyphenate tags added to acts_as_taggable_on

Hi I am using acts_ as_ taggable_on in my app and have it working perfectly however I am looking for information on how to make one modification. At present if I enter a tag which includes spaces, the tag is saved with these spaces and so to view all records with this tag I have something like: http://myapp.local/tag/this%20tag%20has%...

Deploying to multiple Heroku instances

Hi, I've read a couple of the other posts on this issue, but seemed to be stumped on something. I'm trying to have two separate branches that push out to two different Heroku instances - one production and one staging. I suppose my setup will look as follows: Local Myapp | | - master > - master | | | ...

Problem with has_many :through Association in Ruby on Rails

Hi, I've got a problem with a has_many :through association, i cant call the u1.UsersProfileAttributes.find_by_ProfileAttribute_name("icq") method, rails means that this method doesn't exist. The method u1.UsersProfileAttributes.find_by_ProfileAttribute_id(3) works correctly. u1 is a user object. I don't know whats the problem, because ...