Using delayed_job to send emails- files are filename.text.html.erb
Sometimes they show up in my inbox rendered properly and sometimes they show up as HTML code.
I notice that when I stop and start the delayed_job daemon on the server, it seems to help in some cases but not all the time.
Any ideas?
...
I am in the early stages of building an app using Rails 3. User authentication is powered by Authlogic which I have setup pretty much as standard (as per the example docs) and everything is working as expected locally.
I have just deployed the app to a clean server install of Centos 5.4 / NginX / Passenger so staff can start to log in a...
I have a model with a completed:boolean column that I'd like override so I can add some conditional code.
I've never override an ActiveRecord attribute before and wanted to know if the method below is good practice?
class Article < ActiveRecord::Base
def completed=(b)
write_attribute(:completed, b)
# IF b is true then do so...
Hello Stack Anon,
I have X number of image objects that I need to loop through in a view and want to create a new div every 6 objects or so (for a gallery).
I have looked at cycle but it seems to change every other record. Does anyone know of a way to insert code into a view every 6 times?
I could probably do it with nested loops but ...
Right now in my code I'm calling content_for like...
<% content_for :javascript do -%>
<%= "var boxplot_data=#{@survey.boxplot_answers.to_json};" %>
<% end -%>
Rather then having to convert a whole array at once I'd rather add to the array boxplot_data and then have it display as a var. That way I can make my code easier to read...
Code in steps file:
select_date user.date_of_birth, :from => "Date of birth"
Selector fail
When I register with valid user credentials # features/step_definitions/authentication_steps.rb:2
Could not find field: "user_date_of_birth_1i_1i" (Webrat::NotFoundError)
./features/step_definitions/authentication_steps.rb:9:in `/^I regis...
Currently image_tag("file.jpg") produces normal image html tag, BUT src="file.jpg*?7485793246*" what the hell are those numbers anyway and how to disable them?
...
Hi Stackies,
I want to include this module in every ActiveRecord model in my Rails app, without dropping include NotificationResourceableTraits in each file. Is there a way?
module NotificationResourceableTraits
def self.included(base)
base.has_many :notification_resources, :as => :notification_resourceable
base.has_many :not...
I am working on a Rails application which uses categories for items.
My category model is self-joined so that categories can be nested:
class Category < ActiveRecord::Base
has_many :items
# Self Join (categories can have subcategories)
has_many :subcategories, :class_name => "Category", :foreign_key => "parent_id"
belongs_...
I am at an absolute loss as to what I am doing wrong with the following code. I am trying to implement a messaging system within my application, but want it to be handle different types of messages. In this case, I want to create a "request" message of ':message_type => 1'.
Instead of using forms as I usually have, I want to make thi...
In my layout I have
<% @current_user.popups.each do |p| %>
<% content_for :script do %>
<%= "$(document).ready ( function() { $.jGrowl(\"#{p.message}\", { sticky: true }) });" %>
<% end %>
<% end %>
And then in the script section I have
<%= yield :script %>
The problem is that this renders the escaped quotes as \" and ...
Is there a standard way to check if a view layout exists from within a Controller in Rails? I'm trying to allow the user to determine the layout, but it needs to exist first.
...
I've got a model like this:
Stem
-id
-etc
And then I have
Stemrelation
-stem_id
-related_stem_id
-active
I can get the related stems with the following relations
class Stem < ActiveRecord::Base
has_many :stemrelations
has_many :related_stems, :through => :stemrelations
end
class Stemrelation < ActiveRecord::Base
b...
I'm trying to use prawn, prawnto for generating pdfs in a rails application hosted on heroku.
But I'm struggling on the setup.
Is it possible to use prawn, prawnto on heroku?
Is there a guide explaining what I should do?
...
I have two arrays of structs.
array_of_structs1
array_of_structs2
The struct class looks like this, for contextual info:
class Leader < Struct.new(:rank, :user); end
I want to remove the duplicate users from array_of_structs1.
Any assistance would be greatly appreciated!
...
The behavior I'm observing with the Mongoid adapter is that it'll save 'time' fields with the current system timezone into the database. Note that it's the system time and not Rail's environment's Time.zone. If I change the system timezone, then subsequent saves will pick up the current system timezone.
# system currently at UTC -7
@r...
In ruby, you have an attribute called "type" which is the class of the object. Rails stores this at the database in a column called type. So, if I have several blog "types", I can do something like this
def create
@blog = Blog.new(params[:blog])
@blog[:type] = params[:blog][:type]
# ...
end
If I add someone like this, and then l...
Hi...In Rails, is it ok to define logic in a controller with a model. For example, take there is an User Model, which is good design.
1)Leaving the UserModel with the CRUD models and moving all the other User Specific actions to a separate controller or
2)Add the user specific actions to the same UserModels
Thanks :)
...
I have models
class Question < ActiveRecord::Base
WEIGHTS = %w(medium hard easy)
belongs_to :test
has_many :answers, :dependent => :destroy
has_many :testing_questions
end
class Testing < ActiveRecord::Base
belongs_to :student, :foreign_key => 'user_id'
belongs_to :subtest
has_many :testing_questions, :dependent => :dest...
I have a two data arrays sent in from a form, one called transloaded and the other video which is the actual form for the model. I need to get [:video_encoded][:url] and save that to [:video][:flash_url]
This is the passed arguments or transloaded, when I try and access [:transload][:results][:video_encode] I get nil.
print params[:tra...