I am using RedCloth with Rails 2.1.1. The Textile <del> tag markup format (i.e. -delete-) was not translating at all. Tried a few choice options.
> x=RedCloth.new('foobar -blah-')
=> "foobar -blah-"
> x.to_html
=> "<p>foobar <del>blah</del></p>" # WORKED!
> x=RedCloth.new('foobar * -blah-')
=> "foobar * -blah-"
> x.to_html
=> "<p>foob...
So I have a snazzy custom route for login
# routes.rb
map.login '/login', :controller => 'sessions', :action => 'new'
Visit www.asite.com/login and you're there. As is custom with failed login, however, we'll do the following in our action. Note what happens on failed login.
# sessions_controller.rb
def create
self.current_us...
How do you set the timeout for blocking operations on a Ruby socket?
...
I am trying to detect Blackberry user agents in my app, which works fine in my development version. But nothing happens when I redeploy the app in production.
application_helper.rb
def blackberry_user_agent?
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Blackberry)/]
end
application.html.erb
<% if blackb...
So my group is trying to set up a shared-server environment for various and sundry web services. I think we've settled on setting disable_functions and disable_classes site wide in php.ini and php_admin_value to force open_basedir in each app's httpd.conf
for php scripts, and passenger's user switching for ruby scripts.
We still nee...
What are the key differences between the "python way" and the "ruby way"
...
I think I know how to create custom encrypted RSA keys, but how can I read one encrypted like ssh-keygen does?
I know I can do this:
OpenSSL::PKey::RSA.new(File.read('private_key'))
But then OpenSSL asks me for the passphrase... How can I pass it to OpenSSL as a parameter?
And, how can I create one compatible to the ones generated b...
Has Object Prevalance mechanisms been used in an actual Production system? I'm referring to something like Prevayler or Madeleine
The only thing I've found is Instiki, a wiki engine. But since they started they've switched to SQLite. (The actual instiki page is down)
...
I'm trying to get a simple search form working in my RoR site. I've got the following code:
(in note_controller.rb)
def search
@results = Note.find_with_ferret(params[:term]).sort_by(&:ferret_rank)
respond_to do |format|
format.html
format.xml { render :xml => @nootes }
end
end
(in note.rb)
class Note < ...
Hi
How do I get the directory where the rakefile.rb is located?
I want to use this as my root directory to locate everything off.
Cheers
...
Please help, I am stuck here ---
irb> a = "line of text\n line two\n line three"
irb> system("cat > test_file << #{a}")
cat: of: No such file or directory
cat: text: No such file or directory
=> false
...
I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation.
There is an assets table that has key :string (file name) and data :binary (file contents).
I'm using the rubyzip library, and have made it as far as this:
Zip::ZipFile.open(@f...
It's possible to write Markdown content with invalid syntax. Invalid means that the BlueCloth library fails to parse the content and throws an exception. The markdown helper in Rails doesn't catch any BlueCloth exceptions and because of that the complete page fails to render (500 Server Error page is rendered instead).
In my case, users...
What is the simplest way to send mail using Ruby on Rails? Is there a way to send mail directly via ruby and skip all the rails models and complexity, just like php's mail() function?
Thanks for your help.
...
I have written this generator code but it returns 'can't convert nil into String' when I call m.directory inside the manifest. Anyone know what had happened?
class AuthGenerator < Rails::Generator::NamedBase
attr_reader :user_class_name
def initialize(runtime_args, runtime_options={})
@user_class_name="User"
@controller_clas...
I've tried downloading the Rails package and installing it on Windows, but have no idea to make it work.
I have had some experience with this commbination:
PHP 4.x + 5.x (Windows)
LIGHTTPD (Windows)
Connecting to a Firebird Database (Windows)
Can anybody enlighten me?
...
Let's say I have the following ruby code :
def use_object(object)
puts object.some_method
end
and , this will work on any object that responds to some_method,right?
Assuming that the following java interface exists :
interface TestInterface {
public String some_method();
}
Am I right to presume that interfaces are java's wa...
I have a quite old templating system written on top of ERB. It relies on ERB templates stored in database. Those are read and rendered. When I want to pass data from one template to another I use the :locals parameter to Rails render method. For setting default variables of those variables in some templates I use the defined? method whic...
Hello there,
I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range).
DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (API). Any suggestions how I can do that?
...
I am still very new to Ruby (reading through the Pickaxe and spending most of my time in irb), and now that I know it's possible to patch classes in Ruby, I'm wondering when it's acceptable to do so, specifically whether it's acceptable to patch Ruby's base classes. For example: I answered another Ruby question here where the poster want...