I am trying to setup Postfix with SMTP and with TLS on to be used by rails 2.3.10 app.
email.yml settings are as follows:
my mail server is domain1.com
production:
:enable_starttls_auto: true
:address: domain1.com
:domain: domain1.com
:port: 25
:authentication: :login
:user_name: username
:password: passwd
Postfix is co...
I'll use the generic blog example.
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
When querying Post, how do you access its associations (i.e. :comments)?
This should be the easiest thing in the world, but I haven't found any documentation on it. Even http://edgeguid...
<% source.strains.each_with_index do |strain, j| %>
<% if (j == (source.strains.size - 1)) %>
<font size="3">Strain <%= strain[0].appendix %> </font>
<% end %>
<% end %>
I need to get output as
If j value is last one of a loop, then i need to print first value of loop (j[0]). Kindly suggest me or correct abo...
I am trying to do something when I am connecting to my own server(local).
I found request.env from the website, so I am using that array to compare my IPs.
<%
if request.env['HTTP_HOST']!="127.0.0.1"
puts request.env['HTTP_HOST']
else
puts "its Local!"
end
%>
When I run above in rails3, I get nothing printed...
I am new t...
I've been using the geokit and geokit-rails gem for rails for awhile but one question I haven't found answered is how to find the calculated aggregate center for a collection of points. I know how to calculate the distance between two points, but not more than 2.
My reason is, I have a series of points all in the same city... all thing...
Hi ,
I am new to ROR. I am trying add translations to my application. I have added translations for the controllers.
Where to add translations for models as i am not having any /config/locales -> models folder ->en.yml file .
In the model i am having lines like
validates_presence_of :name, :message => "Name cannot be blank!"
If i...
I have a Three documents, here is a sample with fields not shown
class College
include Mongoid::Document
references_many :students,:stored_as => :array, :inverse_of => :colleges
end
class Student
include Mongoid::Document
embedded_in :college, :inverse_of => :students
embeds_one :mark
end
class Mark
include Mongoid::Docum...
I've followed Railscast #235 to try and set up a minimal Facebook authentication.
I've first set up a Twitter authentication, as done by Ryan himself. That worked flawlessly.
I then moved on to adding a Facebook login. However, after authorizing the app the redirect to /auth/facebook/callback fails with:
SSL_connect returned=1 errno=0...
Hi all,
In My controller I am trying to render vanilla JavaScript but am getting an unexpected result. This is the code
class UploadController < ApplicationController
def index
render :file => 'app\views\upload\uploadfile.rhtml'
end
def uploadFile
render :js => "alert('Hello Rails');"
post = Da...
I've been playing around with rail's to_xml, trying to create a really simple rest interface for a project i'm working on.
So far, i've come up with
cards = Card.all(:conditions => {:racedate => Date.today.to_s})
render :xml => cards.to_xml(:include => {:races => { :only => [:id, :number, :race_time, :name] } }, :skip_types => true, :...
I need to let my Rails app connect to a MS SQL Server database and do a simple query to do a lookup. The main DB for the app is MySQL. It just needs to do this SQL Server thing on the side.
What's the best way to do that?
I could write an entirely separate app in Java that connects to the DB and dumps some XML data to the filesystem fo...
In Rails, if I create a scaffold foo, and do rake db:migrate, then now
app/models/foo.rb
is created. So if I go to
script/console (or rails console for Rails 3)
and type
$".grep /foo/i
it is empty. $" is the loaded files. So foo.rb is not loaded yet.
Now I do a Foo.all, and foo.rb should be loaded now.
But when I repeat ...
Hello!
I am developing a small application in Rails 3. In this application users can be connected to each other. I am mainly using two tables to store user data and relations. I want to search these tables with either firstname or lastname to get the contacts of a user.
Table ONE - Profiles
In this table I am storing Firstname, Lastna...
As a Ruby/Rails non-pro, I often want to check out the code for a rails method to see how it's implemented...
For example, I was using "form_for", and I wanted to check out the code to see how it works. The slightly lame way I did this was to just google "rails form_for" which takes me to http://api.rubyonrails.org/classes/ActionView/H...
I've just upgraded to Rails 3, and decided to take it for a whirl with a dummy/sandbox app. The strange thing is I can't seem to get any routes to work!
Here's my problem:
[cobychapple@shiva:Dev]$rails new TestApp
create
create README
create Rakefile
...
[cobychapple@shiva:Dev]$cd TestApp/
[cobychapple@shiva...
This rails validation code is so ugly, and there must be a better way to do it.
The short story is my user is inputting data from test results. Each specific test has 4 measurements. Usually the user inputs all 5 tests (20 measurements), but it's not always required. I just need to check that if a tester started inputting data for a ...
In a rails (2.3.8) app, my server log in development mode shows lines like these:
Completed in 265ms (View: 212, DB: 8)
What accounts for the missing 45ms? Even when repeating a request that does hardly anything, the timing information often reads:
Completed in 14ms (View: 1, DB: 1)
Is the remaining time anything to do with framew...
Hi,
I have a User model which has friends (User.friends with a user_id/friend_id join table called followings). Each user has events (the events table has a user_id column).
For an activity feed, I want to get an array with the last 20 events of the friends of the user. Right now I'm calling the last 20 events for each friend, sorting ...
Hi folks,
Just trying to figure out how to write "or" statements in activerecord conditions without resorting to raw sql - I assume it can be done, but google isn't helping much.
So, to give an example, suppose there's a model "Author" with a one-to-many relationship with 'Books' and a many-to-one relationship with 'Publisher'. How wou...
Hi, I'm currently setting up a new server, and started off with an Ubuntu 8.04 image with a version of Ruby and Rails already preinstalled (I thought it would be easier), and after getting my app running (with a few gems installed), the command line is throwing a wobbly, and trying to install the "Paperclip" gem, is giving the following ...