Simple example:
class A
end
class B < A
end
Then, how can I judge whether class B is inherited from class A?
Is there a method somehow like is_a? or maybe called is_child_of??
I can't find one.
...
I generated a scaffold and put in the type:value but now I need to add another field / db column how do I add another type:value without destroying and restarting my whole project?
rake aborted!
Mysql::Error: You have an error in your SQL syntax; check the manual that corres
ponds to your MySQL server version for the right syntax to use...
it still shows it as an empty field
...
Another question asked about attributes, but I would like to extend the question to associations.
Say I have a simple blogging model
class Discussion < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :discussion
end
Discussion has a #closed? boolean state. I would like to block all entry ...
I have a resume model that has two associations (documents and wizards). A document is the uploaded resume while a wizard is the output from the user using the resume wizard. These are mutually exclusive models. How can I validate that the user has created a document or a wizard when validating resume?
I am building the association in m...
I'm trying to upload an image from Flex to Rails. It uploads fine if I just want to upload the original but when I tried to add Thumbnail I got the following error:
[paperclip] identify '-format' '%wx%h' '/var/folders/RH/RHekFGKME9uDJbX4d4DG3E+++TI/-Tmp-/stream,23830,0.jpeg[0]' 2>/dev/null
[paperclip] An error was received while process...
Ok so I have a optimization that I need to make to a Rails site but the relationsips are not conventional. So my problem is I need a option_groups_from_collection_for_select to go from the state and the cities are below. This can normally be achieved if the State has_many cities and the City belongs_to a state. The problem is the relatio...
I am tired of trapping for nil when looking for a dependent record when most of the time a return of 0 will do nicely. What sort of trouble am I creating for myself by adding "id" to the NilClass thus
class NilClass
def id
0
end
end
What might the unintended consequences be? I know about exists?(), but somehow thought this mi...
I am in the process of hosting my first rails app and I would like to not open it up to the public until I am done with all production work, which might take a few weeks, but I would like to expose it to friends/beta testers. I use authlogic for authentication but I don't even want anybody to go that point, I would like to set up some fo...
Do I need to re-migrate whenever I change the models in Rails? Can someone tell me what migration really does? I am reading it and I am somewhat confused with the difference between the stuff inside db/migrate and the stuff inside app/models.
For example, if I add a has_one realtionship inside my model, do I need to re-migrate this? Why...
I have posts which are sent by users to other users. There are two models - :post and :user, and :post has the following named associations:
belongs_to :from_user, :class_name => "User", :foreign_key => "from_user_id"
belongs_to :to_user, :class_name => "User", :foreign_key => "to_user_id"
Both :user and :post have "is_public" column...
There are some annoyances with using symbols in hashes. For example, the JSON gem that we use always returns strings from any JSON string that's parsed, so wherever we reference a hash generated from decoding JSON, we have to use a combination of strings and symbols to access hashes.
Style-wise, is it ok to keep things consistent thr...
I am reading 'Agile Web Development with Rails.3rd'. When finishing the depot application, I input some Chinese character as user name. But I got this error, it seems this has something to do with Ruby1.9
My environment is window xp, Ruby1.9 Rails 2.3.8 and sqlite3.
The following is the detail about this error:
Showing app/views/lay...
I want to port a social network to Mongoid. The join table between friends is very large. Is there any way for Mongoid to handle this join table out of the box? I've seen a couple of in-model roll-your-own solutions to it, but nothing the looks efficient. Is there a way to handle this? Or is this a case where I shouldn't be using Mo...
for i in (0..5)
if(i==0)
i=4
end
puts i
end
In the above program I excepted the output as - 4 5
But instead it is - 4 1 2 3 4 5
So I conclude that loop variable isnt changing. How can change it? Can anyone tell me?
Actually, In my program I need to save the current state of loop and retrive later so that on the next start...
Ok so I have a small project with two different scaffoldings I've made.In the layouts directory therefor there is two different layout.html.erb files.
My question is how to condense this into just one main layout file that the two scaffolded views share.
Basically my purpose for doing this is so that I only have to have my navigation ...
I am using plupload to perform multipart file uploads. On success, it returns the serverdata that was stored. But i am receiving a string instead of an object containing all my attributes.
This is my controller action:
def upload
@user = User.create! :name => params[:photo_name], :swf_uploaded_data => params[:photo]
re...
I have an Ajax form in my Rails app that contains the Recaptcha markup as provided by the helper in the Ambethia Recaptcha gem:
recaptcha_tags :ajax => true
On submit, the form hits a create action, which responds with the create.js.erb that contains the following:
$('#message-form').replaceWith("<%= escape_javascript(render('message...
Say I have an Article model, and in the article 'new' view I have two buttons, "Publish" and "Save Draft".
My question is how can I know which button is clicked in the controller.
I already have a solution but I think there must be a better way.
What I currently used in the view is:
<div class="actions">
<%= f.submit "Publish" %>
...
Can anyone suggest me the approach of implementing the live chat functionality in my ruby on rails application? Is there any plugin exists to implement this functionality?
Thanks
...