In my application I have a runner script running on schedule (crontab) that needs to connect to database and get some information. I get the following error when I try to run a query ( using Model.find(...) ) :
.../vendor/rails/railties/lib/commands/runner.rb:45: .../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_...
Ok. Given the example of:
http://example.com/news/3226-some-post-title.html
I'm trying to get the 3226. This regexp: http:\/\/interaktywnie.com\/newsy\/(.*).html
doesn't seem to work. Please help.
Thanks.
...
I am about to code something for a Rails app of mine and didn't want to reinvent the wheel, hence my question:
Do you guys know any Rails Plugin that would allow an application to display notification messages that could be user specific and also allow the user to mark them as "don't show this again"?
My vision is to display a top div ...
I went through all the steps described here to set up my OS X machine to allow me to connect to Oracle from a Rails app.
Set up the database.yml file in my app:
development:
adapter: oracle_enhanced
host: [SERVER IP ADDRESS]
database: [ORACLE INSTANCE SID]
username: xxx
password: yyy
encoding: utf8
Also tried it with the ...
I'm using Capistrano run a remote task. My task looks like this:
task :my_task do
run "my_command"
end
My problem is that if my_command has an exit status != 0, then Capistrano considers it failed and exits. How can I make capistrano keep going when exit when the exit status is not 0? I've changed my_command to my_command;echo and i...
I'd like to set up my Rails controller to only perform a create action if the request has a JavaScript or xml payload. I don't want HTML form submits to trigger a create. Ideally, attempting to do so would send you to an page explaining that you can't do that.
I think one solution would be to put a prepend_before_filter on the control...
I am using a shell script to run some runner scripts in my Ruby on Rails app. I need to run it on the production database, but the following:
#!/bin/bash
/usr/bin/ruby RAILS_ENV=production ../script/runner ../lib/tasks.rb
gives an error:
/usr/bin/ruby: No such file or directory -- RAILS_ENV=production (LoadError)
I have tried to f...
My state model looks like this:
class State < ActiveRecord::Base
belongs_to :country
named_scope :order_by_name, :order => :name
validates_presence_of [:country, :name]
def <=>(other)
name <=> other.name
end
end
My country model looks like this:
class Country < ActiveRecord::Base
has_many :states
named_scope :ord...
Hi,
I'm using MySQL fulltext indexes in a Rails 2.3.2 App. I added the index via native SQL in my migration. But there is a known issue causing problems with the schema.rb. Rails doesn't understand fulltext indexes and tries to create a normal index. This will cause an error when creating the database from schema.rb (eg testing, specs, ...
In my current rails app I'm pulling a lot of data from the database into memory so that I can start a long-running background task that I don't want to hit the database every 5 seconds.
This is all working great but I have some inelegant code that I'd like to get rid of if possible.
For an example, I have the situation where I have a U...
Hi all
I tried a few things but this week i feel like my brain's having holidays and i need to complete this thing.. so i hope someone can help me.
I need to create a filelist based on a hash which is saved into a database. The has looks like this:
['file1', 'dir1/file2', 'dir1/subdir1/file3']
Output should be like this:
file1
...
I have a collection select like the following:
<%= f.collection_select :region_id, Region.find(:all), :id, :name, { :prompt => 'Select a State/Province' }, :style => "width: 200px;" %>
Sometimes the prompt from the :prompt option appears, but sometimes it does not. Does anyone know where I could begin to troubleshoot this? Maybe I h...
I have one action which will include the .id for a vendor class through link_to.
That action which is a modification of the new() for a different controller for Reviews needs to pass both the value of the ID from the URL and the session[:user_id] into the database.
How can I grab the value of the vendor.id? Is it possible to not pass...
Hi,
I have a set of routes that are generated dynamically at runtime, but that all point to the same controller i.e.
map.resources :authors, :controller => 'main'
map.resources :books, :controller => 'main'
These all work fine, producing routes like /authors/1, /books, /books/55, etc and then all end up being processed by the 'main' ...
I have a rake task that populates some initial data in my rails app. For example, countries, states, mobile carriers, etc.
The way I have it set up now, is I have a bunch of create statements in files in /db/fixtures and a rake task that processes them. For example, one model I have is themes. I have a theme.rb file in /db/fixtures t...
I need to do conditional validation of models in Rails dependant on one of the fields within the model. This is a follow-up to an earlier question which prompted development of a solution that doesn't feel right.
I have a number of ActiveRecord models all based around an 'Order Model', a shortened version of which is shown below.
clas...
I have the following routing set up in my app (forms belong to a site):
map.resources :sites do |site|
site.resources :forms
end
However, when I try to go to a path for edit (or such) for a form using the helpers (e.g.
edit_site_form_path(form)
or
<%= link_to 'Show', [:site, form] %>
my URLs are coming out with the ID's swapp...
I tried just creating a test.rb file putting it in the public directory then calling it like http://localhost:3000/test.rb but that doesn't seem to work. It thinks I'm trying to download the file. What am I missing here? the little script is below:
#!/usr/local/bin/ ruby
print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html\r\n\r\n...
I am aware of the command to start the sphinx daemon manually. I use a rake task: "rake thinking_sphinx:start" Is it possible to have it start whenever my rails application loads so I don't have to manually type in the command every time?
...
I'm running Rails 2.2.2. I've read a few articles about ruby-prof and profiling a rails app. And I'm confused as to how things are really working.
I was originally using this tutorial
http://snippets.aktagon.com/snippets/255-How-to-profile-your-Rails-and-Ruby-applications-with-ruby-prof
to profile my app, and it works. This involves...