ruby

How to show app data in erb template?

A first look I thought erb accepts any Ruby code, but I've got this strange behaviour... I have an array [of tags for my article], and I want to make a nice display for them. So I'm writing something like this: <ul> <% @post.tags.each do |item| %> <li>item</li> <% end %> </ul> The wrong output looks like this: <ul> <li>...

Tutorials/References/HowTos to learn Glade GTK+ with Ruby?

Hello all, I am trying to design some simple GUIs with Glade to use with Ruby. I am not having so much luck finding tutorials/references on how to actually interface glade with Ruby however. I have found maybe 1 or 2 hello world tutorials that show how to use a button to change a title of a window but is there a reference that tells me ...

Accessing a Plugin from a Rake Task

How would I go about accessing the Bundle-Fu plugin from this rake task? I have tried everything out and nothing seems to work. Note: assets_javascript & assets_css are both arrays of files that are pulled from a central location to keep this rake task and the view DRY. desc "Generate cached css/js files" task :asset_cache_genera...

Custom routes in Rails

Hi! I'm trying to create some nice links over my website. I'm creating a search via tags just now, and I wonder if it is possible to create some nice routes like this: http://myapp.com/search/a_very http://myapp.com/search/nice_set http://myapp.com/search/of_tags or at least like this: http://myapp.com/articles/search/a_very http://m...

Is sleep() a good idea for the main loop of a job-scheduling app

I'm writing a job-scheduling app in Ruby for my work (primarily to move files using various protocol at a given frequency) My main loop looks like this : while true do # some code to launch the proper job sleep CONFIG["interval"] end It's working like a charm, but I'm not really sure if it is safe enough as the application might ...

Best way to generate order numbers for an online store?

Every order in my online store has a user-facing order number. I'm wondering the best way to generate them. Criteria include: Short Easy to say over the phone (e.g., "m" and "n" are ambiguous) Unique Checksum (overkill? Useful?) Edit: Doesn't reveal how many total orders there have been (a customer might find it unnerving to make your ...

Creating non-standard pages with Ruby on Rails

I'm creating a personal site with Ruby on Rails. For the most part, RoR is the perfect tool, allowing for blog posts, comments, etc all rather easy. However, I want to have a few pages that don't require any specific model. An 'About Me' page, for instance, is necessary, and yet doesn't warrant it's own model/controller. In addition, t...

Why are all Rails helpers available to all views, all the time? Is there a way to disable this?

Why can I access helper methods for one controller in the views for a different controller? Is there a way to disable this without hacking/patching Rails? ...

ActiveRecord Join table for legacy Database

I have a legacy database that I'm working on getting ActiveRecord to work with. I've run into a problem with join tables. I have the following: class TvShow < ActiveRecord::Base set_table_name "tvshow" set_primary_key "idShow" end class Episode < ActiveRecord::Base set_table_name "episode" set_primary_key "idEpisode" end ...

Implicit user creation with Authlogic and Authlogic OAuth plugin

I'm trying to write a simple OAuth consumer app in Rails. I'm using Authlogic for handling authentication and the Authlogic OAuth plugin to do the oauth thing. The oauth plugin provides a couple of helpers to render the sign in button: oauth_login_button and oauth_register_button. Together with the Authlogic logics and the plugin's requ...

Why does DataMapper use mixins vs inheritance?

So I'm just curious about this: DataMapper uses a mixin for its Models class Post include DataMapper::Resource While active-record uses inheritance class Post < ActiveRecord::Base Does anyone know why DataMapper chose to do it that way (or why AR chose not to)? ...

rails layout not showing

I upgraded one of my apps from rails to 2.3.2 from 2.0.2. Start up find. However, once I start running any pages, the page will display but it doesn't seem to render any layout code. None of the standard tag such head, body which are in the layout get render. It seems that somehow layout is turned off. I checked the error log and did...

Ruby on Rails - how to render as xml models with has_many associations

I have a ruby on rails application which has two models - ltests and sub_tests. An ltest has a 'has_many' association with sub_tests. In the show method for ltests is as follows. respond_to do |format| format.html # show.html.erb format.xml { render :xml => @ltest } end This renders the ltest object. However the sub_tests belongi...

Rails, searchlogic choose categories with checkboxes

Hello, I am useing searchlogic to search some paintings. Each painting belong to a single category. What I would like to do is add multiple checkboxes to my search form, so that users can mark multiple categories. (joined with or) Is this possible with searchlogic? The query I am looking for is something like this: SELECT * FROM painti...

Ultraviolet + Textmate for Ruby? How do I use this?

Ok so I've had my Macbook for 3-days now. I installed textmate and saw the cool Ruby syntax highlighting thing called Ultraviolet. I've installed the ultraviolet gem, but I don't get what it does. How exactly do I use it? Or is it installed automatically? Is there supposed to be an ultraviolet theme? What exactly does ultraviolet DO? ...

Activerecord error .include? nil

I am writing a rails app, which has some modules and methods loaded via the lib directory, we have also added some methods in restful authentication module, now everytime when i run using mongrel server on production i dont get this error, although because model classes and controller classes are cached, but in development i do get this ...

Setting up Paypal account in Substruct

Hi, I am new to both paypal and substruct. I trying to integrate paypal with 'Substruct'. The problem I am facing is that the payment status codes are not being updated in the admin panel. All of them are on Hold even when paypal sandbox successfully confirmed the orders. From the web somebody suggested that the 'notify_url' needs to be...

What's the best available open source editor/IDE for Ruby?

Possible Duplicate: What Ruby IDE do you prefer? I am purposing to use it for web development using Ruby on Rails. Any suggestions? And this is a CW ;) ...

How could metaprogramming be used to reduce redundancy in this Ruby code?

class Device def initialize(device_id, data_resource) @id = device_id @data_resource = data_resource end def display_device mode = @data_resource.get_display_device_mode(@id) presets = @data_resource.get_display_device_presets(@id) summary = "display_device: #{mode} ($#{presets})" return "* #{summary}" if p...

What are the benefits of using the Rails gem instead od vendor/rails?

I recently started working on a small personal project in Ruby on Rails, and have run into a few things that I couldn't find definitive answers for. If anyone here is knowledgeable enough to help, that would be greatly appreciated. All of my questions are below: What benefit is there to using the Rails Gem instead of having it in vend...