In my Ruby on Rails app, I've got:
class AdminController < ApplicationController
def create
if request.post? and params[:role_data]
parse_role_data(params[:role_data])
end
end
end
and also
module AdminHelper
def parse_role_data(roledata)
...
end
end
Yet I get an error saying parse_role_data is not defined...
I need a collection that is like a set. Basically I'm scanning a long string and adding words to the collection but I want to be able to detect when there are duplicates.
If sets aren't available, what's the most efficient way of doing this in Ruby? Brownie points for example code.
...
Hi,
i'm trying to create watir test that fills inn a textfield by writing feks
"lon" and waiting till the dropdown is triggered and then clicking on the first element in the list.
Writing "lon" should trigger many options like "London, England, Storbritannia", London, Kentucky, USA and etc.
Is it somehow possible to this with watir??...
As per 'unobtrusive JavaScript' recommendations I want to separate my JavaScript logic into
separate files. However I don't know how to organize them.
Should I:
Just throw all application javascript into Application.js file and load it with layout page? This is simple approach but I will end up with a bloated Application.js. Some use...
When using Warbler, what line(s) do I need to add to config/warble.rb to keep it from including Active Record in the bundled gems. I already have excluded Active Record in config/environment.rb as shown below.
config.frameworks -= [ :active_record ]
I tried the same thing only using config.gems in config/warble.rb, but to no avail.
...
I'm not sure I understand scope - does an out-of-scope variable (I'm using Ruby) exist in memory somewhere or does it stop existing (I know you can't access it). Would it be inaccurate to say that an out-of-scope variable does not exist any more?
Maybe this is a philosophical question.
...
Man, I know this is probably dead simple, but I've got some data such as this in one file:
Artichoke
Green Globe, Imperial Star, Violetto
24" deep
Beans, Lima
Bush Baby, Bush Lima, Fordhook, Fordhook 242
12" wide x 8-10" deep
that I'd like to be able to format into a nice TSV type of table, to look something like this:
Name ...
Hi, I'm adding a new method to the String class in Ruby, How can I get the value of the class?
e.g.:
class String
def myMethodName(arguments)
# here I want the string value
end
end
puts "Lennie".myMethodName()
# this should return "Lennie" or whatever the value of the string is.
Thanks
...
I am using Single Table Inheritance and have comments on all the subclasses. I am only using 1 controller for all the different STI types. When the form_for helper generates a URL for a subtype it tries to use a helper for the subtype, but I want it to use the helper for the parent.
This is the error I get:
undefined method `subclasst...
Hi All,
I have installed the acts_as_versioned plugin from github.com in my rails application, and there was a block of code that I don't fully understand, I was hoping someone could clear this up for me
class_eval <<-CLASS_METHODS
def a_bunch_of_stuff
....
end
CLASS_METHODS
I get that the methods inside the block (or whateve...
I have two rails apps on separate virtual servers, but in the same facility. Both apps can communicate via local ip addresses.
This is a two part question:
1) How do I check where the request is originating and limit requests only to those from that location?
2) Do you think this would be secure enough?
My gut is telling me this...
I come from a C# background, and have just started programming in Ruby. The thing is, that I need to know how I can raise events in my classes so that various observers can be triggered when things need to happen.
The problem is the books I have on Ruby don't even mention events, let alone provide examples. Is anyone able to help me?
...
When using class files in Ruby, do you put the 'requires' statements at the top of the file, or inside the class definition?
...
Does anybody know of something similar to Date.js in Ruby? Something that would be able to return a date object from something like: "two weeks from today". The Remember the Milk webapp incorporates this feature into their system and it is incredibly easy to use.
I would use the Date.js library itself but because it is on the client sid...
I find Ruby's each function a bit confusing. If I have a line of text, an each loop will give me every space-delimited word rather than each individual character.
So what's the best way of retrieving sections of the string which are delimited by a tab character. At the moment I have:
line.split.each do |word|
...
end
but that is not ...
I've written a little Ruby script that requires some user input. I anticipate that users might be a little lazy at some point during the data entry where long entries are required and that they might cut and paste from another document containing newlines.
I've been playing with the Highline gem and quite like it. I suspect I am just ...
How do I read/write an ini file in ruby. I have an ini file that I need to
read
change an entry
write out to a different location
How would I do that in ruby? The documentation on this is bleak.
...
What is the best way to handle the need to a user to download 2 files. I'm using *send_data* to send the file to the browser. How can I allow the user to get two dynamically generated files from one request, OR what is a better alternative to do this. A simple example of what I'm trying to do is:
def data_out
output = "foo foo foo...
I'm looking to render an index of all articles along with a full article via json in my rails app, but I'm having a little trouble figuring out how to do it.
Here is my controller now:
if params[:id]
@article = Article.find(params[:id])
else
@article = Article.published.not_draft.by_recent.first
end
respond_to do |format|
for...
Where can I find an explanation of what the "=>" operator means in Ruby?
Let me give more detail. If you have this:
class Acct < ActiveRecord::Base
validates_confirmation_of :password, :email_address, :on => :create
end
What is the '=>' operator doing in this case?
Thanks
...