I have a cache counter setup for a Posts class on the comments field. Posts have many comments, and a comment belongs to a post.
If I add a new comment to a post and save, the counter gets incremented, but if I delete an individual comment, the counter is not touched. Is this not provided automatically, or do I have to roll me own decr...
hello ,
here is my code:
if session[:firsttimestart].nil?
else
@firsttime = false
end
if @firsttime == true
initglobals()
end
session[:firsttimestart]=false
the problem is when i turn off the server and come back to the application the session[:firsttimestart] is still false , it somehow stores this variable in my system withou...
I'm having problems running my Rails unit tests via autotest using Test::Unit 2.0.6. Running tests via rake test:units works perfectly, but when I run the tests from autotest, I get this:
/Code/projectdir/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Test::Unit::TestResult:...
I'm using Heroku, and have added a couple custom domains for my app, i.e. myapp.com and www.myapp.com
My DNS at GoDaddy has three A records for '@' pointing to three separate Heroku IPs, and a CNAME for the 'www' subdomain that points to proxy.heroku.com
What I want to do is redirect any traffic to www.myapp.com to myapp.com. I tried s...
Hi !
I'm currently working on a Rails app which stores plain clear passwords (...). So I'm migrating to Authlogic authentication with a 'standard' SHA512 encryption.
I did that which works fine :
#file /models/user.rb
class User < ActiveRecord::Base
acts_as_authentic { |c|
c.transition_from_crypto_providers = [MyOwnNoCrypto, Au...
In my database, there are some text content, one of them is:
<% abc do %>
ddd
<% end %>
When I dumped it to yaml with to_yaml(), it is like:
content: |-
<% abc do %>
ddd
<% end %>
And then, when I use rake db:fixtures:load, such error occurs:
The exact error was:
NoMethodError: undefined method 'abc' for main:Object...
Hi,
I am trying to populate a ruby on rails select box from a database query, the data comes from 3 tables.
My query
@data = Session.all :include => { :term => :courses }
Object
!ruby/object:Session
attributes:
created_at: 2010-06-17 22:12:05
term_id: "15"
updated_at: 2010-06-17 22:12:05
id: "3"
course_id: "1"
attributes_cache: ...
How could I disable or configure the HoptoadNotifier per controller? Background is that I configured the notifier to report "Method not allowed" exception, eg this is raised when an action is accessed with GET instead of POST.
But I have an autocomplete controller which is scanned by bots (probably to find exploits) by sending GET reque...
I have a User model that has many fights. Fight belongs to User.
There are two foreign keys in the fight table that reference back to the user PK -- challenger_id and challengee_id.
The trick is how do I write the has_many association on the User model so that it returns fights where user_id = challenger_id or challengee_id?
...
Hi!
I want to reformat some helpers in my Rails views. I want to archieve a syntax similar to:
<%=
box :option => 'value' do |b|
b.header "Header of box #1"
%>
Content of Box#1
<%
end
%>
The b.header call is optional.
How would I structure my code to allow this? I guess it's something similar to fields_for in Rails.
Tha...
I'd like to read the Rails 3 source code on printed paper (and preferably in color).
For example, xv6 (http://pdos.csail.mit.edu/6.828/2009/xv6-book/index.html) did a nice job printing their code (http://pdos.csail.mit.edu/6.828/2009/src/xv6.pdf). It even has line numbers and an index. The only thing I would like to add is syntax highli...
im using migration files to create the database tables but i want to set up foreign keys too.
is there any good gem for this? i cant find gems for 3.0.
thanks
...
UPDATE
Got it to work by using has_and_belongs_to_many
Anyone know why this works ?
Hi,
I get the following error when saving with active record
undefined method `reflect_on_association' for Class:Class
my relationships look like this :
class Contact < ActiveRecord::Base
has_many :classes
has_many :sessions, :through => :cl...
I am trying to rake the db:migrations into my heorku instance and I get an error. The FAQ described my error as below:
Cannot change column type
Example: PGError: ERROR: column
“verified_at” cannot be cast to type
“date”
Cause: PostgreSQL doesn’t know how to
cast all the rows in that table to the
specified type. Mo...
i wonder how i can add fixture data in RoR3?
thanks
...
I've been developing Rails apps now for about a year and am starting on a new project (that's actually 3 projects). I'd like to write some gems that can be shared amongst these projects to maintain a common code-base. They'll likely eventually evolve into Rails engines at some point, but to start, just common libraries that can be incl...
there are 2 ways to write validations in RoR3.
validates_length_of :name, :minimum => 5
validates :name, :length => { :minimum => 5 }
both will give the same.
i wonder where i can read more about the latter one. all the options for it.
cause the http://guides.rails.info/activerecord_validations_callbacks.html just mention th...
Hello!
I have model:
class Company < ActiveRecord::Base
attr_accessible :name, :address, :description, :email, :www
validates_presence_of :name, :address, :email
validates_uniqueness_of :user, :name, :email
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create
has_many :items, :...
In Rails 3, I've got an update.js.erb template with one simple line of jquery:
$("#some_div").html("<strong>some_content</strong>");
Upon form submission, all the ajaxy stuff is working fine, but the content in #some_div is being replaced with "<strong>some_content</strong>" instead of some_content. Does anyone have a clue why?
This ...
I am using Rails 2.3.4 and "to_xml" with the :methods => option, and I want to include a Base64 encoded thumbnail image. Is there any way I can specify that that method needs to be wrapped in a cdata tag?
Example:
render :xml => @items.to_xml(
:include => [:photos,:comments],
:methods => [:encoded_thumb]) { |xml|
xml.t...