I have the URL
http://acme.example.com/view/view_container_content/15?javascript_disabled=true&container=aoeu
but I want it to look like
http://acme.example.com/view/container_name/content_name/
My models
Container has many sections
Section has many contents
and belongs to a Container
contents belong to a section
with frien...
I'm running Ruby 1.8.7 with Rails 2.3.5 on Ubuntu 10.04 64-bit. I've written a method that should take a string like this, "École À la Découverte" and output a file-system name like this "ecole_a_la_decouverte":
(Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv "École À la Découverte").downcase.split.join('_')
When I test this line in m...
There is a handy dynamic attribute in active-record called find_or_create_by:
Model.find_or_create_by_<attribute>(:<attribute> => "")
But what if I need to find_or_create by more than one attribute?
Say I have a model to handle a M:M relationship between Group and Member called GroupMember. I could have many instances where member_id ...
My os: windows xp, ruby: 1.8.7, rails: 2.3.5
Everything was fine, but I just installed a "gcc-4.4.0-mingw32-bin", and run gem install rdiscount, then my rails can't start.
Now when I run ruby script/server, or rake gems:install, the following error will occur:
rake aborted!
Malformed version number string mingw32
(See full trace by r...
link_to_remate hos an :href option to unobtrusively add regular links just in case javascript is disabled.
does remote_form_for have something like that
...
Hi all. I'm using the savage_beast forum plugin and tinymce (via the tinymce_hammer plugin) in my rails app. When posting a new post, tinymce works fine. However, when i go to edit a post i get the tinymce editor, but the content in the edit box has all been converted into html.
Can anyone tell me how i get it so that what appears i...
I'm trying to find the results of a model where it queries as the result of two conditions.
I have a search tag that looks for
Model.find(:all, :conditions => "name LIKE params[search]")
but I'd like for the search to find all records where "name LIKE params[search] or description LIKE params[search] .
Is there any way to add an ...
My question is similar to this one http://stackoverflow.com/questions/1342761/how-to-skip-activerecord-callbacks but instead of AR I'm using Mongoid, It seems like that isn't implemented yet in the current version of Mongoid, so I'd like to know what should be an elegant solution to implement it. (if necessary).
...
<%= f.label :type %>
<%= f.select(:type, ["original","print","other"]) %>
I have a photos model and added a drop-down list to the form, when the
option is selected, the correct parameters are passed but it is not
saved to the database.
I've googled this and looked at the api but I'm not too sure what I'm doing.
In my photo model type i...
I'm looking for a best practice solution to be able to keep using redirect :back after a successful destroy action, as many items can be deleted from a variety of listings.
Unfortunately that strategy fails for the one case when the delete is initiated from the item view itself.
What approach do you recommend for this situation?
...
I have a rake task loaddata.rake.
require File.join(File.dirname(__FILE__), 'load_test_data.rb')
namespace :test do
desc "Insert test data into the database"
task(:loadtest => :environment) do
puts "environment = #{RAILS_ENV}"
puts "load_test_data "; load_test_data
puts "DONE!"
end
end
I have another fi...
at the top of my controller, outside of any method, I have
@@javascript_is_disabled = false
and I have methods that that the view calls and invokes something like this
@@javascript_is_disabled = params[:javascript_disabled]
but when I need the @@javascript_is_disabled in completely different method.. it is always false.
I...
Does anyone know how the authenticity token is managed in rails 3? With all the unobtrusive javascript rails 3 articles showing how the html5 data attributes are used I don't see the authenticity token anywhere.
...
Please, help me. I'm confused. I know how to write state-driven behavior of model, but I don't know what should I write in specs...
My model.rb file look
class Ratification < ActiveRecord::Base
belongs_to :user
attr_protected :status_events
state_machine :status, :initial => :boss do
state :boss
state :owner
state ...
I keep getting an error from the ActiveModel:EachValidator module when I try to use it as follows:
class AnswerValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || "question not answered") if value.nil? and !record.errors[attribute].include?(options[:m...
I want a link to remote to have a rel tag, because I want to use facebox with it.
I had it working with a regular link to... but I needed the link to remote to handle the event that a user doesn't have javascript enabled.
this, currently does't work (except for the non-javascript part )
<%= link_to_remote "Ask a Question",
...
Hi there,
The following is beginning to become a huge problem for us.
We have about 15 Rails applications for our enterprise, running on a massive server. The problem occurs when two or three applications are wildly popular and they start taking up all the instances in the PassengerMaxPoolSize. As soon as that happens, other applicatio...
I've a simple script that looks at Twitter username and gets me the location. But some of the username doesn't exist and I get error:
/usr/lib/ruby/1.8/open-uri.rb:277:in `open_http': 404 Not Found (OpenURI::HTTPError)
I've tried to rescue it, but I can't to make it work. Can anyone help? Thanks
a = []
my_file = File.new("location.t...
Hi all,
Currently we are using method_missing to catch for calls to SEO friendly actions in our controllers rather than creating actions for every conceivable value for a variable. What we want are URLS like this:
/students/BobSmith
and NOT /students/show/342
IS there a cleaner solution than method_missing?
Thank you!
...
I'm trying to use this number:
294670251400
This number will be an attribute in a model that is keeping counter tabs on membership cards. The membership cards have three four digit vanity sets.
But when I update_attribute to contain this, the number is reset to mySQL's max int :
2147483647
Anyone have a workaround to this ?
...