Here is the route:
map.resources :networks do |network|
network.resources :channels, :name_prefix => nil
end
Here is what I have in my for my form.
<% form_for ([@network, @channel]) do |f| %>
...
<% end %>
I get an undefined method error since form_for is trying to call "network_channel_path". This error occurs because I h...
Hi
I need a list with all models (class_names) which have the pattern "Cube" at the end.
example:
all my models:
ModelFoo, ModelBar, ModelBarCube, Mode2BarCube
what I need:
['ModelBarCube', 'Mode2BarCube']
...
I don't get the point how can I do that code with an select helper?
<% @cube_names.each do |cube| %>
" <% if @cube_name == cube %> selected="selected"<% end %>><%= cube %>
<% end %>
I have a list (@cube_names) and want a HTML select box width all values of the list and the default value (param @cube_name) sh...
Hey,
I have a beginner ruby question about multi dimensional arrays.
I want to sort entries by year and month. So I want to create a multi-dimensional array that would contain years -> months -> entries of month
So the array would be like:
2009 ->
08
-> Entry 1
-> Entry 2
09
-> Entry 3
2007...
I'm at a loss here. When running in Dev mode (script/server) I the error "undefined local variable or method 'id' for #<InsertModelNameHere:0x7f19bdb87dc8>" at random times when I try to list entries for a number of my models. If I refresh the page it works fine and I'm assuming that I only see it in dev because everything gets reloaded...
Where can I find the documentation on the modifiers for gsub? \a \b \c \1 \2 \3 %a %b %c $1 $2 %3 etc.?
Specifically, I'm looking at this code... something.gsub(/%u/, unit) what's the %u?
...
Hello, I am writing a Ruby script to generate a CSV file.
My understanding is that each line in a CSV file is a row in a table.
Right now my script generates something looks like this
Vancouver, Calgary,
Routes1,
Routes2,
Routes3,
Vancouver, Toronto
etc,
etc,
etc
but I need it to make it look like this to import it to a DB
Vancouv...
Is there a way in Ruby to take a symbol or string and turn it into a class of the same name?
For instance, if I have a class such as
class Bob
def talk
puts "Hi, I'm bob"
end
end
And a method I have somewhere else in the code is passed a symbol :bob, can I in some way turn that into the class Bob? Maybe something like
b = ...
I have a has_many_polymorphs relationship between a Candidate and many events of various type. In particular, a Candidate creates a Created event when it is created.
class Candidate < ActiveRecord::Base
has_many_polymorphs :events, :through => :candidate_events,
:from => Event::Base.included_in_classes.m...
I'm using Ruby's scan() method to find text in a particular format. I then output it into a string separated by commas. The text I'm trying to find would look like this:
AB_ABCD_123456
Here's the what I've come up with so far to find the above. It works fine:
text.scan(/.._...._[0-9][0-9][0-9][0-9][0-9][0-9]/)
puts text.uniq.sort.joi...
I need a function, is_an_integer, where
"12".is_an_integer? returns true
"blah".is_an_integer? returns false
how can i do this in ruby? i would write a regex but im assuming there is a helper for this that i am not aware of
...
I got this code in a single file snippet.rb and it runs as expected. This script if from dzone snippet that fetches the thumbnail of the URL at the current time.
Now I wan to integrate this functionality with Rails and here I'm stuck how to begin.
Should I put this in some ruby file inside lib directory or make it modules???
I'm not muc...
Hello
I have an array which for arguments sake looks something like this:
a = [[1,100], [2,200], [3,300], [2,300]]
Of those four sub-arrays, I would like to merge any where the first element is a duplicate. So in the example above I would like to merge the 2nd and the 4th sub-arrays. However, the caveat is that where the second eleme...
Will I learn anything in Metaprogramming Ruby that is not covered in any of: Programming Ruby, The Ruby Cookbook, The Ruby Programming Language or The Ruby Way, all of which have at least a chapter's material covering metaprogramming in Ruby?
It also has about a third of the book devoted to Rails, which I'm not particularly interested i...
I'm considering using Sequel for some of my hairier SQL that I find too hard to craft in Active Record.
Are there any things I need to be aware of when using Sequel and ActiveRecord on the same project? (Besides the obvious ones like no AR validations in sequel etc...)
...
For the last several days, I've been struggling to get ruby on rails to work on my mac. The main culprit is MySQL. Every time I fix one thing, another error shows up. I upgraded/downgraded MySQL to play nice with ruby, rail and gems, but nothing. My latest error is:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please...
When I attempt to use net/https with JRuby 1.3.0RC1 with the jruby-openssl-0.5.1 gem installed I get the following error:
Error in JobsRequiringReportDataProcessor: JRuby only supports F_SETFL for fcntl/ioctl currently
/opt/bin/jruby/lib/ruby/gems/1.8/gems/jruby-openssl-0.5.1/lib/openssl/ssl.rb:56:in `initialize'
/opt/bin/jruby/lib/ruby...
I have been studying ruby for the past few days and I have noticed there is Ruby on Rails. What is the difference between the two? Do they work to together? Is the syntax the same?
...
I have added into my routes file prefix value to each map.resources line. So it all looks like this:
map.resources :subjects, :path_prefix => ':company'
I have even added this line for default behavior
map.connect ':company/:controller/:action/:id'
which is not necessary (I believe) because all the routes are handled with resource...
I have this code
<% if approved %>
<td>Flow Number</td>
<% end %>
and I'd like to shorten it using statement modifiers. Of course I can use
<%="<td>Flow Number</td>" if approved -%>
but is there a shorter way? I'd also like to get the markup out of quotes.
...