I am trying to make an application, that sends an email when user registers.
i put in the smtp settings for gmail in the config/application.rb file and the mail function looks like
mail(:to => "[email protected]", :subject => "Mail!", :from => "[email protected]", :content_type => "text/html")
now when i see the logs, i see that it says mail ha...
Here is the situation, I use jquery for everything in my rails app with the exception of a certain action in a certain controller where I need to use prototype (for a graph gem) AND jquery for evreything else. this causes the $ conflict, which I resolve by using the jQuery.noConflict and assign $j for jquery and use $ for prototype. Ther...
I have used Globalize2 to create a table and translate the original table.
http://github.com/joshmh/globalize2
Here are my tables:
Threads: id, comment_count
Thread_translations: id, thread_id, title, body
I created a thread via:
Thread.create(:title => "Hello", :body => "Awesome!")
It was successfully created.
But when I wanted...
Hello guys,
A rails newbie here
I have 2 actions in my controller 1) index 2) refine_existing.
Both of them show the results in the same format.
How do I reuse the index.html.erb file?
When I try the following, it complains about refine_existing.erb not being present.
def refine_existing
...
respond_to do |format|
format.html...
This happens in Ruby on Rails's View, where there is a hash for another partial. This hash has about 20 key/value pairs.
There is (in HAML)
- if (some_conditon)
= render :partial => 'some_name', :locals => a_hash.merge({ :extra => true })
- else
-# a lot more processing, including concatenating the partials and return as json
- ...
Here is what I have in my enviornment.rb. I understand there have been
issues with restarting because of a bug in the "daemons" gem and that
the ghazel-daemons fixes it. But its not working in my case. I am
using the collectiveidea 2.1.0--pre version of DJ, rails 2.3.5.
config.gem 'delayed_job', :source => 'http://rubygems.org', :versio...
In my rails app, a user can have multiple directories which have further files and subdirectories, just like Dropbox. The only difference is Dropbox has user files both on the cloud and the client PC as well, whereas I want to store the entire directory on the cloud.
How should i do it??
...
I have a bunch of different controllers that all deal with the same basic model. For example...
FoobarController
FoobarShareController
FoobarTakeController
FoobarToolsController
FoobarVerifyController
They all do various things to the foobar model and I kind of wanted a better way to organize them along with other things that deal w...
Is there an easy way to rename a controller? The only way I know of is to either do it by hand or generate a new controller move the code over and destroy the old one. Seems like there has to be a programmatic way to do this.
...
Hello,
In a controller I try to render a javascript google ad to print it into some HTML using JSONP, like this
<script type="text/javascript"><!--
google_ad_client = "pub-23222424";
google_alternate_color = "FFFFFF";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googl...
Hi guys, I'm starting out with Ruby on Rails and I know of a few stuff already, but I was wondering if there was a "right" way of going about developing a project. Right now, I would create my models first using [script/generate model MyModel] then modifying them until I feel they are complete enough. Then I'd go for [script/generate sca...
Hi,
I have two sortable lists and everything works fine unless one of the columns is empty.
For example if the left list is empty and the user tries to drag an item from the right list and drop it into the left list, the drop can not happen. It just returns back to it's spot in the right list.
If both right and left has items then ...
In Rails3 there seems to be a problem when chaining two scopes (ActiveRelations) that each have a different include:
Consider these two scopes, both of which work fine on their own:
First scope:
scope :global_only, lambda { |user|
includes(:country)
.where("countries.area_id <> ?", user.area) }
Work.global_only(user) => (cut list of...
To get all the ActiveRecord goodies your class must inherit from ActiveRecord::Base:
class Post < ActiveRecord::Base
Why not ask the user to include ActiveRecord as a module instead?
The advantage of this approach is that Rails could automatically include ActiveRecord in all classes in the models directory, making it completely trans...
I have a rails model User that has name, email and hash fields.
I save data to this by doing:
@u = User.create(:name=>'test', :email=>"[email protected]")
@u.save
How can I incorporate the before_create callback so that before saving the record the hash value gets a hash string by following code:
Digest::SHA1.hexdigest('something secr...
I have a query based on the answer to this question: http://stackoverflow.com/questions/2939061/handling-ties-when-ranking-from-the-highest-to-the-lowest/2939079#2939079
Given this dataset:
Name | Score
Mike | 5
John | 3
Mary | 3
Matt | 0
The following query returns a user array containing the correct values.
User.find_by_sql("SELECT...
Hello,
I was hoping someone could suggest some best practices for configuring Rails applications using a database (i.e. persisting configuration settings to a database rather than a flat file). My reasoning for this is that I have an application that will run on multiple servers and there are some configuration settings that are fairly ...
What would be the best way to go about giving users the ability to share a private link that enables anyone who clicks it to view a certain page/document/item that have privacy restrictions in place?
In my case:
A User creates events which are limited to certain groups of relationships in the database (namely: friends, friends of frien...
I have two classes Message and User. Message has sender_id and recipient_id both foreign keys for User. How to build relationship where I'll be able to get user for both sender and recipient, like @message.sender.name and @message.recipient.name
I tried to do it by this way:
class Message < ActiveRecord::Base
belongs_to :sender, :...
I have a simple statement like this:
@employee.update_attributes(:subscribed=>false)
but this is not updating the boolean column field subscribed. It throws a warning saying:
WARNING: Can't mass-assign these protected attributes: subscribed
...