ruby-on-rails

Current ruby and rails resources (2010)

Can you great and knowledgable programmers please point me to some current and updated Ruby/Rails blogs/sites? I am also looking for an active forum for lively discussions on ruby/rails. I already tried to google for them but as I already mentioned on SO, many of the links on google seem to be to sites that are no longer updated. ...

Overriding a resource route to / (root) in Rails3: not changing the path helper?

Hi, I am quite new to Rails3, I basically created a subscribers scaffolding, I only want my app to respond to new and create actions. So in config/routes.rb I defined: resources :subscribers, :only => [:new, :create] Which works this way GET /subscribers => subscribers#new POST /subscribers => subscribers#create Now I want my a...

In Ruby on Rails, do you test controllers and views or mostly models?

I have heard that at the very least, if you write unit tests for only models and try to keep the bulk of your logic in the model, you are pretty well off. Is there any merit to testing controllers and views or any other part of the framework? ...

create custom html helpers in ruby on rails

I've starting programming on ASP.NET MVC Framework a year ago. Recently. I've learning Ruby On Rails Framework There is "custom html helper" feature in ASP.NET MVC So I can create my own html helper <%= Html.MyOwnHtmlHelper() %> I've learned that there is html helpers in Ruby such as <% text_area %> which render at html I have a ...

Rails 2.x and Unicode

I've read several Stack Overflow questions re. this and haven't been able to find an answer. I'm running Rails 2.3.3 and am having an issue properly displaying Unicode characters from MySQL in my app and even in the Rails console. Connecting to MySQL via my ssh console and querying works fine. However, soon as I retrieve a record co...

How do I use a URL to link to the create action in Ruby on Rails?

I'm trying to use the following URL to create an object from a bookmarklet: http://localhost:3000/posts?title=Welcome&amp;body=To but it takes me to the index action. How do I get it to point to the create action? I know that both index and create share the same URL, using GET and POST respectively, but I'm not sure how to specify whi...

Is twitter still on Rails?

Is twitter still on Rails? ...

Ruby on Rails. Unicode routes

Hi. Is it possible to set a Unicode string as a segment of a path in Rails? I try the following: # app/controllers/magazines_controller.rb class MagazinesController < ApplicationController def index end end ...

dynamic tree menu using awesome nested set

how do you create a dynamic tree menu helper using awesome nested set (or any other set plugin) in rails ? the result should look something like this: <div class="level_0"> <span class="title">Categroy</span> <div class="level_1> <span class="title">SubCategroy</span> <div class="level_2> SubSubcategory SubSubca...

Barby failing to generate some QR Codes - nil.rszf

In irb data = "2 1058 657682" barcode = Barby::QrCode.new(data) File.open('barcode.png', 'w+') {|f| f.write barcode.to_png(:height => 100, :margin => 25, :xdim => 100) } Generates error: ActionView::TemplateError (/Library/Ruby/Gems/1.8/gems/barby- 0.4.0/vendor/rqrcode/lib/rqrcode/qrcode/qr_code.rb:296:in `...

Ruby on Rails won't start in cPanel

Hi all, Here is the error from mongrel.log for my particular application. First time i've tried moving it to my web server (running cPanel, obviously not maintained by me...). Before this was developing locally...can someone provide some pointers with the exception? I've done digging around and have gotten no where. /home/midoucom/r...

what is the equivalent of ActiveRecord#establish_connection in Mongoid ?

Table is a Mongoid model that must dinamically map to different databases/tables # app/models/table.rb class Table include Mongoid::Document end # in app/controllers/some_controller.rb def index Table.connection.database = :other_database # <- How to do this ??? Table.table_name = params[:id] # <- How to do this ??? @records...

Controller edit method, modify object data before commit

When a user saves a form, I want to do the following check before saving if header2 is null header2 = header1 I don't want to add validation and stop the save action, because header2 is only needed in rare occasions. I'm not sure how to have the update method in the controller do this. The command to commit the update is if @entry.u...

Creating new Ruby string helper without argument params

I really had a hard time figuring out how to word this question, but in essence, I want to do this: model = MyModel.new model.title = "foo bar" model.title.to_id #=> "foo_bar" I have an ActiveRecord class for MyModel class MyModel < ActiveRecord::Base def to_id(str) str.downcase.gsub(" ", "_") end end but, of course, it's l...

Getting 'uninitialized constant' error when using delegate in belongs_to in model

Hello. I'm implementing a view on a model with three tables, one of them join table. Here are the tables: Recipe: class Recipe < ActiveRecord::Base # validates :name, :presence => true # validates :directions, :presence => true # has_and_belongs_to_many :ingradients has_many :ingredients_recipes has_many :ingredients, :t...

Setting a field to read-only in Rails after it's created

Hi, I'd like to protect a user-generated entry in a field after its initial creation. I'm asking the user for a unique name when they set up a project, and I want to stop that being changeable after the creation. Is there a way to do this in Rails? Can I set it as attr_accessible at first then switch it to to attr_protected? Cheers ...

How can I remove this logic from my view?

I am trying to wrap my head around this problem. I know views shouldn't have that much logic in them. I have an app with users, posts and comments. Users have many posts and comments. class User < ActiveRecord::Base has_many :posts has_many :comments Posts belong to users and have many comments. class Post < ActiveRecord::Base has_ma...

RadRails error when creating new project

i just installed RadRails. Now i want to create a new project. It creates the directory structure and the gives this error. Can somebody tell me what's the problem? <internal:lib/rubygems/custom_require>:29:in `require': 126: Das angegebene Modul wurde nicht gefunden. - c:/ruby/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5-x86-mswin32-60/lib...

How can I serve static content from outside of the project - rails

Without using a symlink, how can I serve images that are outside of the rails project? I though there might be some routes magic but I can find what I'm looking for... Lets say images are at ~/images and the application is at ~/app. ...

Authlogic HTTP Basic UserSession.find returns nil, means declarative_authorization can't get a current_user

When using Authlogic's HTTP Basic auth, UserSession.find returns nil since the session appears not to be set. As a result, declarative_authorization, which references the usual current_user method (as below), can't find a current user. def current_user_session return @current_user_session if defined?(@current_user_session) @curr...