Confession: I only use private and public visibility for my methods!
I have a feeling this is a bad thing. But in Rails it just doesn't seem to come up as an issue.
Does anyone have an example in Rails where it would be a big mistake not to use protected visibility?
...
good morning guys, i have a problem of selecting all records which are inactive or active in a database, but if i select all estates and all status it returns all the estates and their different status, active or inactive, but if i select all estates and active status it returns all the estates and display that they are all active, same ...
Possible Duplicate:
What IDE / Editor do you use for Ruby on Linux?
what do you consider the best ide for developing ruby and rails on linux? thanks.
...
What is the recommended way of handling the following type of situations:
Supposing I have a model called Cart, that has a 1-1 relationship with the model Person and the same PK (the user's id).
In the index method of my cart_controller I want to check if a Cart exists for the current user.
If I do Cart.find(the_user_id) and a cart does...
I'm using rails 2.0.5 with cookie session.
but cookie session has serious problem wis the possibility of replay attacks.
How do I prevent replay attacs with cookie store?
I hope a plug in of Rails 2.0 use or concrete source example codes.
Could you help me?
more information
more information
...
When a new resource is created and it needs to do some lengthy processing before the resource is ready, how do I send that processing away into the background where it won't hold up the current request or other traffic to my web-app?
in my model:
class User < ActiveRecord::Base
after_save :background_check
protected
def background_...
HI
I tried using a javascript function call in the submit tag of a form_remote_for but it is not able to find the function im calling.
if i call the same function from form_remote_for then ajax stops working.
can ny one help me how can i call an javascript function when im using form_remote_for NOT FORM_REMOTE_TAG....????
...
I have a rails app in which I am trying to do some full text searching on. Ferret seems to be the most popular choice. However, I have an issue.
I have a 'thing' which contains an id which determines if a user can see it (and therefore search it), but I want to search sub-models of this 'thing' which are related to my 'thing' but don'...
I have defined translated attributes and model names in the translation file and Modelname.human_attribute_name(...) returns the correctly translated attribute name, but the attribute names in the error messages are untranslated.
What is needed that the attribute names in the error messages are translated?
...
I am taking an input string from a user and using that as the parameters for a command line back-end program.
What is the best way to ensure that this input is "safe"? Aka they haven't inserted "; cd /; rm -rf" or some other ugliness into field?
Without any sanitizing I have...
@query = params[:query]
@result = %x( mycommand #{@query}...
I am building a web application in RubyOnRails, which is based on a large body of data. The application makes for powerful navigation and intersection of the data, as well as a community model for adding more data.
In that respect one could compare it with StackOverflow.com: a big bunch of data, structured in a fairly simple way.
I int...
In a Rails application, I'm using this to get a random row from a MySQL table:
contact = Contact.find(:all, :limit => 1, :order => 'RAND()')[0]
Even though the table only has about 20,000 rows it takes a couple seconds. Does anyone know of a faster way?
Update
Also tried just running the SQL in the console...
SELECT * FROM `conta...
A bit of a newbie question on rails associations.
I have a Bug model, and a Status model. Status is basically just a key/value pair table. Out of the choices available, I would say Bug has_one Status makes the most sense. However, according to this
Content belongs_to ContentTemplate. Go
back and look at how I described the
probl...
Rails has a nice set of filters (before_validation, before_create, after_save, etc) as well as support for observers, but I'm faced with a situation in which relying on a filter or observer is far too computationally expensive. I need an alternative.
The problem: I'm logging web server hits to a large number of pages. What I need is a...
What's an effective approach to debug NameErrors in Rails?
I'm trying to use the desert plugin (0.5.0) and the edge version of Community_Engine. I've started from scratch and gone through the installation instructions. When I
attempt to start my server, I get this error: "Constant RAILS_END from
rails_end.rb not found (NameError)". Pro...
I have a model like this:
class Transaction < ActiveRecord::Base
def amount
self[:amount].abs
end
def transaction_type
read_attribute(:amount) > 0 ? :credit : :debit
end
def transaction_type=(type)
if type == :credit || type == 'credit'
self[:amount] = amount.abs
elsif type == :debit || type == 'debit'
...
I have a basic rails application test with a user model that has a photo field handled with paperclip. I created the views to be able to create/edit an user and the photo uploading is working nicely.
<h1>Editing user</h1>
<% form_for :user, @user, :url => user_path(@user), :html => { :method => "put", :multipart => true } do |f| %>
...
I need to learn and adpot the MVC methodology for building web apps. Which is the better way to go given that I have experience with ASP .NET Webforms - ASP .NET MVC or Ruby on Rails?
I've heard people going gaga over RoR and its simplicity and its features such as scaffolding, ActiveRecord, convention over configuration etc.
However,...
I'm trying to setup my charset in a html view in a RoR application.
I configured already the charset by meta equiv tag:
**meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" **
It didn't work, so i tried to change my .htaccess (its a RoR application running under apache) but here is my problem. Normally i could use th...
I'm busy creating a very simplistic ruby on rails app that won't need a lot things that are loaded in the ruby on rails environment by default.
I won't be using mysql, just one model that fetches data from a Yaml file. So I'm thinking I won't be needing ActiveRecord, or at least a large part of it. ( Correct me if I'm wrong here );
How...