Hi,
I don't get why SQL does not like my query:
@unreadmessages = Message.find(:all, :conditions => ["receiver_id = ? AND receiver_archived = ? AND read = ?", self.current_user, "No", "No"])
There is a different way to write this, but I want to keep my style consistent (this one avoids SQL injections, I gather.).
Thanks for your inp...
Hello.
In my controller, I have this:
user.save
if user.leveled_up==true
flash[:notice]="HOOOORAY!!!"
end
and in my model I have:
before_save :check_xp
# ....
def leveled_up=(leveled_up)
@leveled_up=leveled_up
if @leveled_up==true
self.statpoints+=5
hp=max_hp
end
end
def leveled_up
@le...
I have a teams table and a players table and I'm wanting to find all teams that do not have players associated with them. The players table is associated via a team_id column. I'm using Ruby on Rails for this so I have a Team and a Player model.
...
I'm using the facebooker gem which creates a variable called facebook_session in the controller scope (meaning when I can call facebook_session.user.name from the userscontroller section its okay). However when I'm rewriting the full_name function (located in my model) i can't access the facebook_session variable.
...
I've heard that Rails 3 is "just around the corner".
Does that mean sometime in 2009?
Has a release date been discussed/conjectured about?
...
Sigh... I feel like a big newbie on this one, so lets say I have a few models:
class Question < ActiveRecord::Base
has_many :answers
belongs_to :user
end
class Answer < ActiveRecord::Base
belongs_to :question
has_one :user
end
class User < ActiveRecord::Base
has_many :questions
has_many :answers, :through => :questions
end...
I have a standard many-to-many relationship between users and roles in my Rails app:
class User < ActiveRecord::Base
has_many :user_roles
has_many :roles, :through => :user_roles
end
I want to make sure that a user can only be assigned any role once. Any attempt to insert a duplicate should ignore the request, not throw an error ...
So when you use scaffolding Rails will kick out some layouts that are xhtml transitional. I prefer strict.
Is there some setting somewhere to do this? Or shall I continue to edit the doctype in the layouts?
...
Hi,
I'm doing something like this:
Item.find_by_solr('name:ab*')
and it says it returns 297 results:
=> #<ActsAsSolr::SearchResults:0xb6516858 @total_pages=1, @solr_data={:docs=>[doc1, doc2, doc3...]}, :max_score=>1.6935261, :total_pages=>1, :total=>297}, @current_page=1>
Item.count_by_solr('name:ab*') also returns 297.
Yet when ...
Hi everyone, I have a 'template' system in my CMS rails app. Basically the whole HTML template is stored in a database column and it has key code in the string (like <!--THEME_Body-->) that gets replaced with content generated by the application.
I use an actual layout to render the template. All that is in the layout is:
<%= generate_...
I have 2 models:
Video:
class Video < ActiveRecord::Base
belongs_to :user
has_many :thumbnails
attr_accessor :search, :saveable
accepts_nested_attributes_for :thumbnails, :allow_destroy => true
en
d
Thumbnail:
class Thumbnail < ActiveRecord::Base
belongs_to :video
end
I am using the YouTubeG gem in order to search for...
Hey guys,
This is my two model relationship.
team has_many groups
group belongs_to team
I have a sweeper that runs in my group model.
In my Team controller I have this in the after_create callback.
def after_create
self.groups.create(:name => DEFAULT_GROUP, :active => true, :description => "Parent group")
end
I am getting error...
Hey guys,
I was wondering if anyway knows how I can access the user ID from the session object in Rails using the Authlogic gem ?
I have a sweeper that runs to expire a fragment specific for a user:
def expire_cache_for(record)
ActiveRecord::Base.logger.debug "team: #{record.team_id}"
ActiveRecord::Base.logger.debug("User: #...
I'm working in a non-privileged environment, and my Rails application's root url is http://foo.com/bar.
What is the simplest way to tell Rails that, for example, my stylesheets are in /bar/stylesheets, not /stylesheets, and make model_url point to /bar/model/baz instead of /model/baz?
...
I am using Builder::XmlMarkup to produce data structures in XML format for a RESTful API server.
Recently, I discovered a bug where the pretty-printing from Builder::XmlMarkup produced an element full of whitespace text instead of an empty element as it should.
For example, this code:
xml.outertag do
xml.list do
# Some code whic...
I have called the partial file form the loop. now when i update , i do not actually get updated result but need to do refresh for getting updated result.
the code is like this :
the file1
@folders.each do |@folder|
= render :partial => 'folders/group_list'
the partial file
%div{:id => "group_list_#{@folder.id}"} // this is th...
I have cucumber features working fine and rspec spec working fine i can run both cucumber features and spec spec and they all work but now im looking at getting autospec to run but running does the produces the following
Warning: $KCODE is NONE.
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.3.90/lib/cucumber/step_definition.rb:100: warni...
I just installed aptana, and i have the repository for the rails project.. So i open a new project and point it to my repository.. and it opens... But i can't do any rake tasks. Under rake tab, it says that "no rake tasts found. Likely cause is no Rakefile for the project"
But i can see the Rakefile in the project.. Can anyone help?
...
I have a rails application where I allow users to enter comments. The comments are displayed back like so
<%= simple_format(sanitize(c.comment)) %>
If a user enters the following the in the comment link this link gets appended to the end of the rails root directory. So if someone clicked on the link the would go to
www.somedomain.com...
Hello everyone,
I have a Rails application with several models-views-controllers which have some similar characteristics, for example 5 different models can be commented on, voted on or tagged, I am also heavily using external plugins.
At the moment I introduced comments, votes, tags, etc. only to a single model (and its view and cont...