Displaying 20 results from an estimated 2000 matches similar to: "error messages, loops and saves, actionmailer and finaly authentication"
2005 Mar 10
10
Some Basic Questions
Sorry I can''t access IRC from work so I hope you don''t mind me asking my newbie
questions here:
1) I have the following code:
@post = Post.find(@params[''id''])
@comments = Comment.find_all "post_id = #@params[''id'']", "created_on ASC"
And I am have problems with the second line. I want to pass the id from my post
to the
2005 Sep 06
1
error_messages_for - different controllers, one view [revisited]
Hi there,
some time ago there were two posts on this subject on this list:
One way that might satisfy the elegence factor is to treat your
> comment controller as a component in this case, calling
> render_component within your post controller where you need to process
> the comment.
>
> http://manuals.rubyonrails.com/read/chapter/73
>
> There are a few ways you could do
2005 Mar 10
6
problems with ActionMailer
I''m having some problems with ActionMailer and I''m hoping that someone can
help. I''ve followed the tutorial on "How To Send Emails With Action
Mailer" <URL:
http://wiki.rubyonrails.com/rails/show/HowToSendEmailsWithActionMailer >,
I''ve generated a mailer -- "notifier.rb" -- and I''ve added the following
method to the
2005 Mar 17
4
Specifying Which Environment I Am In
After I have uploaded my app where do I specify that my app should now
use production environment settings and not development?
Can that be done dynamically so that I don''t have to reset a value once
I upload website?
Thanks for your help!
2005 Apr 16
2
Authorization
Hi,
Maybe I ask again for something what is wasn''t able to find anything.
Is there simple way how to process authorizations?
My imagine is that some action for controllers are allowed only to few
users. E. g. Everybody can look category list, but only registred user can
edit or add.
In best way, when user is signup, rails will remember his rights like:
adding_category = false
2006 Jul 13
1
error_messages_for
I can''t seem to figure out how to validate a few fields some1 please
help me out
model---------
class Record < ActiveRecord::Base
validates_presence_of :sw, :flex
end
controller------------
class RecordController < A;;icationController
def new
@record = Rrecord.new
@product = Product.find(params[''product_id''])
end
def create
2005 Jan 07
3
multicolumn primary keys in activerecord
hi,
I''ve got the following tables in mysql notation:
CREATE TABLE `nodes` (
`id` int(11) NOT NULL auto_increment,
`parent_id` int(11) default ''0'',
`group_id` int(11) default ''0'',
PRIMARY KEY (`id`),
);
CREATE TABLE `groups` (
`parent_id` int(11) NOT NULL default ''0'',
`id` int(11) NOT NULL auto_increment,
2007 Nov 20
3
How to test views with Nested Resources and Partials
Hi everyone,
I am relatively new to rspec and I am running into a wall in testing my
views. I have a RESTful resource Contracts with a nested resource of
Line_items.
I am trying to figure out how to test the "edit" form of the Line_items.
What complicates this is the nested routing and how to account for it,
and that there is a partial form (_form.haml) that both the edit.haml
and
2005 Apr 27
3
caches_page questions
I''m attempting to use caches_page to speed up the loading of certain
pages on my site, and have run into a couple questions:
1) The site has ''states'' (as in U.S. states), so I have a State model
and a States controller. Going to http://sitename/states/ routes you to
the States controller, ''index'' action. The States controller looks like so:
class
2005 Mar 10
6
Expiring Cache Fragments and fcgi
First let me say that Rails caching is very very cool. The traffic
(and responsiveness) I''ve saved by added 10 lines of ruby code would
be enourmous, if I actually had traffic... ;)
Sweepers as observers are great, btw. Since every page of my side is
dynamic, once I did some DB optimization I''m caching the content of
the index page which was taking the bulk of the time to load
2005 Mar 10
8
Login controller additions
I have added roles and roles_users table and updated the model so that
my users can have multiple roles.
("Admin" role does always have id = 1).
I have added these methods to my application controller.
<code>
helper_method :is_admin?
helper_method :is_user?
def is_admin?
if @session[''user'']
@session[''user''].roles.find(1)
2006 May 18
6
Newbie:problem when using validates*
Hi,
I have performed the cookbook tutorial. Before tailoring the views and
controllers, when I put in the model recipe.rb:
validates_uniqueness_of :title
validates_length_of :title, :within => 1...20
And I tried to introduce some new recipe without the above conditions I
got the message:
---------------------------------------------------
New recipe
1 error prohibited this category from
2005 Mar 10
2
NoMethodError in Event_type#create
I am new Ruby on Rails, so excuse me if my question seems pretty obvious.
I am trying to validate uniqueness of a filed:
class EventType < ActiveRecord::Base
belongs_to :sport
validates_uniqueness_of :event_type
end
When I run it, I get this error message:
Showing /event_type/new.rhtml where line #27 raised undefined method
`each'' for nil:NilClass
<select
2005 Mar 11
4
actionmailer settings
A couple questions:
1) How does rails no if you are in your test, dev or production
environment?
2) Does anyone have an actionMailer server settings that will work on
your standard local machine? I will use the one provided for my
textdrive account but for testing on my machine I am getting connection
refused.
Thanks.
Your Friend,
Jonathan Kopanas
http://www.kopanas.com
2005 Aug 07
8
Ajax forms and redirects
Here is an example that seems perfect for Ajax that I have not seen
implemented nor can figure out how to do it. I am hoping someone can
give me some pointers.
On the sign-up page, I would like to do my validations (password
length, username uniqueness,etc ) Ajax-style. But if all validates,
then redirect to the success page. The combining of redirection to a
new page with Ajax is throwing me.
2006 Jan 09
4
How to carry parameters to a new page?
Hello,
I have a page where user can register him/herself to the site.
If the user enters something wrong, or leaves blank textboxes, I want to
reload the page and tell the user what went wrong. Also the
textbox-values the user already entered, should be kept in the
textboxes.
For example, in my user-controller:
if @username.length == 0
redirect_to :action =>
2006 Mar 23
3
How to redisplay submitted data on validation error?
Hi!
If i have an object it''s easy.
But i''m making a simple contact form and i check if email address is
correct. If it''s not i redisplay the form with the info that there was
an error (should i use redirect_to or render :action? what''s the
difference?), but all previously submitted data is lost.
I tried creating variables using names of the form fields, but
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others.
If all of you have time, please follow this (the question still
relates to the previous posts by me):
I have provided full steps to reproduce the symptoms.
If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on
Windows XP Professional.
1. First, the setup
MySQL
-----
create database testdb;
2005 Mar 10
7
Order of Processing
It seems odd to me that the layout is processesed after the view. When I set a
variable inside the view it does not have an impact on the layout file. But
when I set it in the controller it does.
Is this the way it works or is it possible that I am doing something wrong?
2006 Mar 30
1
Passing values to a Partial
Hi,
I cannot seem to find out how to pass in a value to a partial. Can
anyone help me?
What I am doing(in the code below) is calling a function in my
controller called setobject. This function just redraws the partial. I
want to be able to change the value @objectname, redraw my partial and
have it be able to use that value. The first the page is drawn it works,
but when i call setobject it