Apologies because I know this has come up before but I am simply having no luck search archives or Google other than this wiki article: http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. What I want to do is have a contact form in my app. It doesn''t need a db table, just the fields, but I do want to use ActionMailer to send the messages. I generated the mailer and thought a simple model class, controller and form would do the trick. Controller and form were (if I did this right) okay but not getting anywhere with the model. Controller has new and send_message actions, new shows the form and send_message, which is the form''s action, calls the generated mailer. Could some kind soul help with the model? The fields are :name, :email, :subject, :message, :ipaddress, :c_date (the last two are set by :initialize in the model). If I get this done I''ll update that wiki article with the lesson learned. Thanks, Bill
Hi Bill, Is it possible just to make your model so that it does not inherit from ActiveRecord? It would only be a volotile object, but from what your suggesting in your email, I think this is what your after. eg class Contact I hope this is what your looking for On 11/14/05, Bill Lazar <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > Apologies because I know this has come up before but I am simply having no > luck search archives or Google other than this wiki article: > http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. > > What I want to do is have a contact form in my app. It doesn''t need a db > table, just the fields, but I do want to use ActionMailer to send the > messages. I generated the mailer and thought a simple model class, > controller and form would do the trick. Controller and form were (if I did > this right) okay but not getting anywhere with the model. Controller has new > and send_message actions, new shows the form and send_message, which is the > form''s action, calls the generated mailer. > > Could some kind soul help with the model? The fields are :name, :email, > :subject, :message, :ipaddress, :c_date (the last two are set by :initialize > in the model). > > If I get this done I''ll update that wiki article with the lesson learned. > > Thanks, > Bill > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Yes, that''s exactly what I have in mind. Probably I''m too new but how to write the model class is confusing me, if someone could get me started that would be a big help. Bill Liquid wrote:> Hi Bill, > > Is it possible just to make your model so that it does not inherit from > ActiveRecord? It would only be a volotile object, but from what your > suggesting in your email, I think this is what your after. > > eg > class Contact > > I hope this is what your looking for > > > On 11/14/05, *Bill Lazar* > <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: > > Apologies because I know this has come up before but I am simply > having no luck search archives or Google other than this wiki > article: > http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. > > What I want to do is have a contact form in my app. It doesn''t need > a db table, just the fields, but I do want to use ActionMailer to > send the messages. I generated the mailer and thought a simple model > class, controller and form would do the trick. Controller and form > were (if I did this right) okay but not getting anywhere with the > model. Controller has new and send_message actions, new shows the > form and send_message, which is the form''s action, calls the > generated mailer. > > Could some kind soul help with the model? The fields are :name, > :email, :subject, :message, :ipaddress, :c_date (the last two are > set by :initialize in the model). > > If I get this done I''ll update that wiki article with the lesson > learned. > > Thanks, > Bill
Hey Bill, When you generate your model, simply remove the "< ActiveRecord::Base" within the class definition, Inside /app/models/my_new_model.rb could contain.. class MyNewModel def method # put your logic inside here end End You will not get all the nice features of ActiveRecord, such as find, before_filter, etc. But from what it sounds like you are after, you don''t really need most of them anyways. Your controller will function just as it would normally, so create inside /app/controllers/my_new_model.rb the following: class MyNewModelController < ApplicationController def index end end And put your view inside the views/my_action_model/index.rhtml which can contain any X/HTML you want Warmest regards, Nathan. -------------------------------------------------------------- Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT Inimit Innovations Phone 604.724.6624 www.inimit.com Fax 604.444.9942> -----Original Message----- > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Bill Lazar > Sent: November 13, 2005 3:29 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails] Re: contact form/no db table? > > Yes, that''s exactly what I have in mind. Probably I''m too new > but how to write the model class is confusing me, if someone > could get me started that would be a big help. > > Bill > > Liquid wrote: > > Hi Bill, > > > > Is it possible just to make your model so that it does not inherit > > from ActiveRecord? It would only be a volotile object, but > from what > > your suggesting in your email, I think this is what your after. > > > > eg > > class Contact > > > > I hope this is what your looking for > > > > > > On 11/14/05, *Bill Lazar* > > <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: > > > > Apologies because I know this has come up before but I am simply > > having no luck search archives or Google other than this wiki > > article: > > > http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. > > > > What I want to do is have a contact form in my app. It > doesn''t need > > a db table, just the fields, but I do want to use > ActionMailer to > > send the messages. I generated the mailer and thought a > simple model > > class, controller and form would do the trick. > Controller and form > > were (if I did this right) okay but not getting > anywhere with the > > model. Controller has new and send_message actions, new > shows the > > form and send_message, which is the form''s action, calls the > > generated mailer. > > > > Could some kind soul help with the model? The fields are :name, > > :email, :subject, :message, :ipaddress, :c_date (the > last two are > > set by :initialize in the model). > > > > If I get this done I''ll update that wiki article with the lesson > > learned. > > > > Thanks, > > Bill > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Nathan, Thanks! That''s more or less what I did but I''m not sure what to put in the model methods so the fields are proper instance variables. I''m a noob and AWD doesn''t seem to cover this. Bill Nathaniel S. H. Brown wrote:> Hey Bill, > > When you generate your model, simply remove the "< ActiveRecord::Base" > within the class definition, > > Inside /app/models/my_new_model.rb could contain.. > > class MyNewModel > def method > # put your logic inside here > end > End > > You will not get all the nice features of ActiveRecord, such as find, > before_filter, etc. But from what it sounds like you are after, you don''t > really need most of them anyways. > > Your controller will function just as it would normally, so create inside > /app/controllers/my_new_model.rb the following: > > class MyNewModelController < ApplicationController > def index > end > end > > And put your view inside the views/my_action_model/index.rhtml which can > contain any X/HTML you want > > Warmest regards, > Nathan. > > -------------------------------------------------------------- > Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT > Inimit Innovations Phone 604.724.6624 > www.inimit.com Fax 604.444.9942 > > > >>-----Original Message----- >>From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Bill Lazar >>Sent: November 13, 2005 3:29 PM >>To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>Subject: [Rails] Re: contact form/no db table? >> >>Yes, that''s exactly what I have in mind. Probably I''m too new >>but how to write the model class is confusing me, if someone >>could get me started that would be a big help. >> >>Bill >> >>Liquid wrote: >> >>>Hi Bill, >>> >>>Is it possible just to make your model so that it does not inherit >>>from ActiveRecord? It would only be a volotile object, but >> >>from what >> >>>your suggesting in your email, I think this is what your after. >>> >>>eg >>>class Contact >>> >>>I hope this is what your looking for >>> >>> >>>On 11/14/05, *Bill Lazar* >>><blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>><mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>> >>> Apologies because I know this has come up before but I am simply >>> having no luck search archives or Google other than this wiki >>> article: >>> >> >>http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. >> >>> What I want to do is have a contact form in my app. It >> >>doesn''t need >> >>> a db table, just the fields, but I do want to use >> >>ActionMailer to >> >>> send the messages. I generated the mailer and thought a >> >>simple model >> >>> class, controller and form would do the trick. >> >>Controller and form >> >>> were (if I did this right) okay but not getting >> >>anywhere with the >> >>> model. Controller has new and send_message actions, new >> >>shows the >> >>> form and send_message, which is the form''s action, calls the >>> generated mailer. >>> >>> Could some kind soul help with the model? The fields are :name, >>> :email, :subject, :message, :ipaddress, :c_date (the >> >>last two are >> >>> set by :initialize in the model). >>> >>> If I get this done I''ll update that wiki article with the lesson >>> learned. >>> >>> Thanks, >>> Bill
Bill- You could use a Struct to make your non AR model act like an Active Record. Here is a little irb session that will make this hopefully more clear: >> MyModel = Struct.new(:name, ?> :email, :subject, :message, :ipaddress, :c_date) => MyModel >> @a = MyModel.new(''Jimmy'', ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', ''Hello World!'', ''120.0.0.1'', ''11/14/2005'') => #<struct MyModel name="Jimmy", email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", subject="Foo Bar", message="Hello World!", ipaddress="120.0.0.1", c_date="11/14/2005"> >> @a.name => "Jimmy" >> @a.message => "Hello World!" So define your model like this: my_model.rb MyModel = Struct.new (:name, :email, :subject, :message, :ipaddress, :c_date) and now you can use it almost just like an Active Record in your controller: def create_mailer @content = MyModel.new(params[:name], params[:email], params [:subject], params[:message], params[:ipaddress], params[:c_date]) Mailer.deliver_notification(@content) end Or whatever you want to use your new struct model for. Let me know if this works for you. I think I understand what you are trying to do and this is the way that I have been doing email only forms that don''t need to have an AR model backing them. Cheers- -Ezra On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote:> Yes, that''s exactly what I have in mind. Probably I''m too new but > how to write the model class is confusing me, if someone could get > me started that would be a big help. > > Bill > > Liquid wrote: >> Hi Bill, >> Is it possible just to make your model so that it does not inherit >> from ActiveRecord? It would only be a volotile object, but from >> what your suggesting in your email, I think this is what your after. >> eg >> class Contact >> I hope this is what your looking for >> On 11/14/05, *Bill Lazar* <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >> Apologies because I know this has come up before but I am simply >> having no luck search archives or Google other than this wiki >> article: >> http://wiki.rubyonrails.com/rails/pages/ >> HowToUseRailsWithoutADatabase. >> What I want to do is have a contact form in my app. It doesn''t >> need >> a db table, just the fields, but I do want to use ActionMailer to >> send the messages. I generated the mailer and thought a simple >> model >> class, controller and form would do the trick. Controller and >> form >> were (if I did this right) okay but not getting anywhere with the >> model. Controller has new and send_message actions, new shows the >> form and send_message, which is the form''s action, calls the >> generated mailer. >> Could some kind soul help with the model? The fields are :name, >> :email, :subject, :message, :ipaddress, :c_date (the last two are >> set by :initialize in the model). >> If I get this done I''ll update that wiki article with the lesson >> learned. >> Thanks, >> Bill > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Bill, I believe that the instance variables are set as you use them. Alternativley you could use the *attr_accessible *macro... attr_accessible :email, :subject, :message, :ipaddress, :c_date This will create the required get and set methods so that you can access the variables as per a normal AR model. You can over write these methods if you want (say for the ipaddress) or you could just instantiate a model like an AR @my_model = Contact.new(params[:contact]) I''m not sure if this works tho... On 11/14/05, Bill Lazar <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > Nathan, > > Thanks! That''s more or less what I did but I''m not sure what to put in the > model methods so the fields are proper instance variables. I''m a noob and > AWD doesn''t seem to cover this. > > Bill > > Nathaniel S. H. Brown wrote: > > Hey Bill, > > > > When you generate your model, simply remove the "< ActiveRecord::Base" > > within the class definition, > > > > Inside /app/models/my_new_model.rb could contain.. > > > > class MyNewModel > > def method > > # put your logic inside here > > end > > End > > > > You will not get all the nice features of ActiveRecord, such as find, > > before_filter, etc. But from what it sounds like you are after, you > don''t > > really need most of them anyways. > > > > Your controller will function just as it would normally, so create > inside > > /app/controllers/my_new_model.rb the following: > > > > class MyNewModelController < ApplicationController > > def index > > end > > end > > > > And put your view inside the views/my_action_model/index.rhtml which can > > contain any X/HTML you want > > > > Warmest regards, > > Nathan. > > > > -------------------------------------------------------------- > > Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT > > Inimit Innovations Phone 604.724.6624 > > www.inimit.com <http://www.inimit.com> Fax 604.444.9942 > > > > > > > >>-----Original Message----- > >>From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Bill Lazar > >>Sent: November 13, 2005 3:29 PM > >>To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>Subject: [Rails] Re: contact form/no db table? > >> > >>Yes, that''s exactly what I have in mind. Probably I''m too new > >>but how to write the model class is confusing me, if someone > >>could get me started that would be a big help. > >> > >>Bill > >> > >>Liquid wrote: > >> > >>>Hi Bill, > >>> > >>>Is it possible just to make your model so that it does not inherit > >>>from ActiveRecord? It would only be a volotile object, but > >> > >>from what > >> > >>>your suggesting in your email, I think this is what your after. > >>> > >>>eg > >>>class Contact > >>> > >>>I hope this is what your looking for > >>> > >>> > >>>On 11/14/05, *Bill Lazar* > >>><blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > >>><mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: > >>> > >>> Apologies because I know this has come up before but I am simply > >>> having no luck search archives or Google other than this wiki > >>> article: > >>> > >> > >>http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. > >> > >>> What I want to do is have a contact form in my app. It > >> > >>doesn''t need > >> > >>> a db table, just the fields, but I do want to use > >> > >>ActionMailer to > >> > >>> send the messages. I generated the mailer and thought a > >> > >>simple model > >> > >>> class, controller and form would do the trick. > >> > >>Controller and form > >> > >>> were (if I did this right) okay but not getting > >> > >>anywhere with the > >> > >>> model. Controller has new and send_message actions, new > >> > >>shows the > >> > >>> form and send_message, which is the form''s action, calls the > >>> generated mailer. > >>> > >>> Could some kind soul help with the model? The fields are :name, > >>> :email, :subject, :message, :ipaddress, :c_date (the > >> > >>last two are > >> > >>> set by :initialize in the model). > >>> > >>> If I get this done I''ll update that wiki article with the lesson > >>> learned. > >>> > >>> Thanks, > >>> Bill > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks for the help. I tried this suggestion but get an error still: wrong number of arguments (1 for 0) on this line: @contact = Contact.new(@params[:contact]) Same error (except 6 for 1) if I use: @contact = Contact.new(params[:name], params[:email], params[:subject], params[:message], params[:ipaddress], params[:c_date] ) Bill Ezra Zygmuntowicz wrote:> Bill- > > You could use a Struct to make your non AR model act like an Active > Record. Here is a little irb session that will make this hopefully more > clear: > > >> MyModel = Struct.new(:name, > ?> :email, :subject, :message, :ipaddress, :c_date) > => MyModel > >> @a = MyModel.new(''Jimmy'', > ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', ''Hello > World!'', ''120.0.0.1'', ''11/14/2005'') > => #<struct MyModel name="Jimmy", > email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", subject="Foo Bar", > message="Hello World!", ipaddress="120.0.0.1", c_date="11/14/2005"> > >> @a.name > => "Jimmy" > >> @a.message > => "Hello World!" > > So define your model like this: > > my_model.rb > > MyModel = Struct.new (:name, :email, :subject, :message, :ipaddress, > :c_date) > > > and now you can use it almost just like an Active Record in your > controller: > > def create_mailer > @content = MyModel.new(params[:name], params[:email], params > [:subject], params[:message], params[:ipaddress], params[:c_date]) > Mailer.deliver_notification(@content) > end > > Or whatever you want to use your new struct model for. Let me know if > this works for you. I think I understand what you are trying to do and > this is the way that I have been doing email only forms that don''t need > to have an AR model backing them. > > > Cheers- > > -Ezra > > > > On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote: > >> Yes, that''s exactly what I have in mind. Probably I''m too new but how >> to write the model class is confusing me, if someone could get me >> started that would be a big help. >> >> Bill >> >> Liquid wrote: >> >>> Hi Bill, >>> Is it possible just to make your model so that it does not inherit >>> from ActiveRecord? It would only be a volotile object, but from >>> what your suggesting in your email, I think this is what your after. >>> eg >>> class Contact >>> I hope this is what your looking for >>> On 11/14/05, *Bill Lazar* >>> <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>> Apologies because I know this has come up before but I am simply >>> having no luck search archives or Google other than this wiki >>> article: >>> http://wiki.rubyonrails.com/rails/pages/ >>> HowToUseRailsWithoutADatabase. >>> What I want to do is have a contact form in my app. It doesn''t need >>> a db table, just the fields, but I do want to use ActionMailer to >>> send the messages. I generated the mailer and thought a simple >>> model >>> class, controller and form would do the trick. Controller and form >>> were (if I did this right) okay but not getting anywhere with the >>> model. Controller has new and send_message actions, new shows the >>> form and send_message, which is the form''s action, calls the >>> generated mailer. >>> Could some kind soul help with the model? The fields are :name, >>> :email, :subject, :message, :ipaddress, :c_date (the last two are >>> set by :initialize in the model). >>> If I get this done I''ll update that wiki article with the lesson >>> learned. >>> Thanks, >>> Bill > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > 509-577-7732
Thanks for the suggestion but this didn''t do the trick. Bill Liquid wrote:> Bill, > > I believe that the instance variables are set as you use them. > Alternativley you could use the *attr_accessible *macro... > > attr_accessible :email, :subject, :message, :ipaddress, :c_date > > This will create the required get and set methods so that you can access > the variables as per a normal AR model. You can over write these > methods if you want (say for the ipaddress) or you could just > instantiate a model like an AR > > @my_model = Contact.new(params[:contact]) > > I''m not sure if this works tho... > > > > On 11/14/05, *Bill Lazar* < > blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>> wrote: > > Nathan, > > Thanks! That''s more or less what I did but I''m not sure what to put > in the model methods so the fields are proper instance variables. > I''m a noob and AWD doesn''t seem to cover this. > > Bill > > Nathaniel S. H. Brown wrote: > > Hey Bill, > > > > When you generate your model, simply remove the "< > ActiveRecord::Base" > > within the class definition, > > > > Inside /app/models/my_new_model.rb could contain.. > > > > class MyNewModel > > def method > > # put your logic inside here > > end > > End > > > > You will not get all the nice features of ActiveRecord, such as find, > > before_filter, etc. But from what it sounds like you are after, > you don''t > > really need most of them anyways. > > > > Your controller will function just as it would normally, so > create inside > > /app/controllers/my_new_model.rb the following: > > > > class MyNewModelController < ApplicationController > > def index > > end > > end > > > > And put your view inside the views/my_action_model/index.rhtml > which can > > contain any X/HTML you want > > > > Warmest regards, > > Nathan. > > > > -------------------------------------------------------------- > > Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT > > Inimit Innovations Phone 604.724.6624 > > www.inimit.com > <http://www.inimit.com> Fax 604.444.9942 > > > > > > > >>-----Original Message----- > >>From: > rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > <mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >>[mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > <mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org>] > On Behalf Of Bill Lazar > >>Sent: November 13, 2005 3:29 PM > >>To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > <mailto:rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >>Subject: [Rails] Re: contact form/no db table? > >> > >>Yes, that''s exactly what I have in mind. Probably I''m too new > >>but how to write the model class is confusing me, if someone > >>could get me started that would be a big help. > >> > >>Bill > >> > >>Liquid wrote: > >> > >>>Hi Bill, > >>> > >>>Is it possible just to make your model so that it does not inherit > >>>from ActiveRecord? It would only be a volotile object, but > >> > >>from what > >> > >>>your suggesting in your email, I think this is what your after. > >>> > >>>eg > >>>class Contact > >>> > >>>I hope this is what your looking for > >>> > >>> > >>>On 11/14/05, *Bill Lazar* > >>><blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > >>><mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>> > wrote: > >>> > >>> Apologies because I know this has come up before but I am simply > >>> having no luck search archives or Google other than this wiki > >>> article: > >>> > >> > >>http://wiki.rubyonrails.com/rails/pages/HowToUseRailsWithoutADatabase. > >> > >>> What I want to do is have a contact form in my app. It > >> > >>doesn''t need > >> > >>> a db table, just the fields, but I do want to use > >> > >>ActionMailer to > >> > >>> send the messages. I generated the mailer and thought a > >> > >>simple model > >> > >>> class, controller and form would do the trick. > >> > >>Controller and form > >> > >>> were (if I did this right) okay but not getting > >> > >>anywhere with the > >> > >>> model. Controller has new and send_message actions, new > >> > >>shows the > >> > >>> form and send_message, which is the form''s action, calls the > >>> generated mailer. > >>> > >>> Could some kind soul help with the model? The fields are :name, > >>> :email, :subject, :message, :ipaddress, :c_date (the > >> > >>last two are > >> > >>> set by :initialize in the model). > >>> > >>> If I get this done I''ll update that wiki article with the lesson > >>> learned. > >>> > >>> Thanks, > >>> Bill
You could try it like this: def send_message @contact = Contact.new @contact.name = params[:name] @contact.email = params[:email] and so on... end See if that works for you. Or if you still have problems then fire up script/console and play with your Contact model to get a feel for how it works. I''m sure their is just something simple missing that is giving you those errors. Cheers- -Ezra On Nov 13, 2005, at 6:23 PM, Bill Lazar wrote:> Thanks for the help. I tried this suggestion but get an error still: > > wrong number of arguments (1 for 0) > > on this line: > > @contact = Contact.new(@params[:contact]) > > Same error (except 6 for 1) if I use: > > @contact = Contact.new(params[:name], params[:email], params > [:subject], params[:message], params[:ipaddress], params[:c_date] ) > > Bill > > Ezra Zygmuntowicz wrote: >> Bill- >> You could use a Struct to make your non AR model act like an >> Active Record. Here is a little irb session that will make this >> hopefully more clear: >> >> MyModel = Struct.new(:name, >> ?> :email, :subject, :message, :ipaddress, :c_date) >> => MyModel >> >> @a = MyModel.new(''Jimmy'', ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', ''Hello >> World!'', ''120.0.0.1'', ''11/14/2005'') >> => #<struct MyModel name="Jimmy", email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", >> subject="Foo Bar", message="Hello World!", >> ipaddress="120.0.0.1", c_date="11/14/2005"> >> >> @a.name >> => "Jimmy" >> >> @a.message >> => "Hello World!" >> So define your model like this: >> my_model.rb >> MyModel = Struct.new >> (:name, :email, :subject, :message, :ipaddress, :c_date) >> and now you can use it almost just like an Active Record in your >> controller: >> def create_mailer >> @content = MyModel.new(params[:name], params[:email], params >> [:subject], params[:message], params[:ipaddress], params[:c_date]) >> Mailer.deliver_notification(@content) >> end >> Or whatever you want to use your new struct model for. Let me know >> if this works for you. I think I understand what you are trying >> to do and this is the way that I have been doing email only forms >> that don''t need to have an AR model backing them. >> Cheers- >> -Ezra >> On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote: >>> Yes, that''s exactly what I have in mind. Probably I''m too new >>> but how to write the model class is confusing me, if someone >>> could get me started that would be a big help. >>> >>> Bill >>> >>> Liquid wrote: >>> >>>> Hi Bill, >>>> Is it possible just to make your model so that it does not >>>> inherit from ActiveRecord? It would only be a volotile object, >>>> but from what your suggesting in your email, I think this is >>>> what your after. >>>> eg >>>> class Contact >>>> I hope this is what your looking for >>>> On 11/14/05, *Bill Lazar* <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>>> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>>> Apologies because I know this has come up before but I am >>>> simply >>>> having no luck search archives or Google other than this wiki >>>> article: >>>> http://wiki.rubyonrails.com/rails/pages/ >>>> HowToUseRailsWithoutADatabase. >>>> What I want to do is have a contact form in my app. It >>>> doesn''t need >>>> a db table, just the fields, but I do want to use >>>> ActionMailer to >>>> send the messages. I generated the mailer and thought a >>>> simple model >>>> class, controller and form would do the trick. Controller >>>> and form >>>> were (if I did this right) okay but not getting anywhere >>>> with the >>>> model. Controller has new and send_message actions, new >>>> shows the >>>> form and send_message, which is the form''s action, calls the >>>> generated mailer. >>>> Could some kind soul help with the model? The fields are :name, >>>> :email, :subject, :message, :ipaddress, :c_date (the last >>>> two are >>>> set by :initialize in the model). >>>> If I get this done I''ll update that wiki article with the >>>> lesson >>>> learned. >>>> Thanks, >>>> Bill >> -Ezra Zygmuntowicz >> WebMaster >> Yakima Herald-Republic Newspaper >> ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org >> 509-577-7732 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Oh, also make sure that the only line in your contact.rb model file is this: Content = Struct.new (:name, :email, :subject, :message, :ipaddress, :c_date -Ezra On Nov 13, 2005, at 6:23 PM, Bill Lazar wrote:> Thanks for the help. I tried this suggestion but get an error still: > > wrong number of arguments (1 for 0) > > on this line: > > @contact = Contact.new(@params[:contact]) > > Same error (except 6 for 1) if I use: > > @contact = Contact.new(params[:name], params[:email], params > [:subject], params[:message], params[:ipaddress], params[:c_date] ) > > Bill > > Ezra Zygmuntowicz wrote: >> Bill- >> You could use a Struct to make your non AR model act like an >> Active Record. Here is a little irb session that will make this >> hopefully more clear: >> >> MyModel = Struct.new(:name, >> ?> :email, :subject, :message, :ipaddress, :c_date) >> => MyModel >> >> @a = MyModel.new(''Jimmy'', ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', ''Hello >> World!'', ''120.0.0.1'', ''11/14/2005'') >> => #<struct MyModel name="Jimmy", email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", >> subject="Foo Bar", message="Hello World!", >> ipaddress="120.0.0.1", c_date="11/14/2005"> >> >> @a.name >> => "Jimmy" >> >> @a.message >> => "Hello World!" >> So define your model like this: >> my_model.rb >> MyModel = Struct.new >> (:name, :email, :subject, :message, :ipaddress, :c_date) >> and now you can use it almost just like an Active Record in your >> controller: >> def create_mailer >> @content = MyModel.new(params[:name], params[:email], params >> [:subject], params[:message], params[:ipaddress], params[:c_date]) >> Mailer.deliver_notification(@content) >> end >> Or whatever you want to use your new struct model for. Let me know >> if this works for you. I think I understand what you are trying >> to do and this is the way that I have been doing email only forms >> that don''t need to have an AR model backing them. >> Cheers- >> -Ezra >> On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote: >>> Yes, that''s exactly what I have in mind. Probably I''m too new >>> but how to write the model class is confusing me, if someone >>> could get me started that would be a big help. >>> >>> Bill >>> >>> Liquid wrote: >>> >>>> Hi Bill, >>>> Is it possible just to make your model so that it does not >>>> inherit from ActiveRecord? It would only be a volotile object, >>>> but from what your suggesting in your email, I think this is >>>> what your after. >>>> eg >>>> class Contact >>>> I hope this is what your looking for >>>> On 11/14/05, *Bill Lazar* <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>>> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>>> Apologies because I know this has come up before but I am >>>> simply >>>> having no luck search archives or Google other than this wiki >>>> article: >>>> http://wiki.rubyonrails.com/rails/pages/ >>>> HowToUseRailsWithoutADatabase. >>>> What I want to do is have a contact form in my app. It >>>> doesn''t need >>>> a db table, just the fields, but I do want to use >>>> ActionMailer to >>>> send the messages. I generated the mailer and thought a >>>> simple model >>>> class, controller and form would do the trick. Controller >>>> and form >>>> were (if I did this right) okay but not getting anywhere >>>> with the >>>> model. Controller has new and send_message actions, new >>>> shows the >>>> form and send_message, which is the form''s action, calls the >>>> generated mailer. >>>> Could some kind soul help with the model? The fields are :name, >>>> :email, :subject, :message, :ipaddress, :c_date (the last >>>> two are >>>> set by :initialize in the model). >>>> If I get this done I''ll update that wiki article with the >>>> lesson >>>> learned. >>>> Thanks, >>>> Bill >> -Ezra Zygmuntowicz >> WebMaster >> Yakima Herald-Republic Newspaper >> ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org >> 509-577-7732 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Thanks for the continuing help! I tried a bunch of variations, including using the console, but all result in the same error: undefined method `name='' for #<Contact:0x38440d8>. I know you said to only have the Struct.new line in the model class file but I wonder--is the controller is finding the model? model is app/models/contact.rb controller is app/controllers/contact_controller.rb Bill Ezra Zygmuntowicz wrote:> You could try it like this: > > def send_message > @contact = Contact.new > @contact.name = params[:name] > @contact.email = params[:email] > and so on... > end > > See if that works for you. Or if you still have problems then fire > up script/console and play with your Contact model to get a feel for > how it works. I''m sure their is just something simple missing that is > giving you those errors. > > > Cheers- > -Ezra > > On Nov 13, 2005, at 6:23 PM, Bill Lazar wrote: > >> Thanks for the help. I tried this suggestion but get an error still: >> >> wrong number of arguments (1 for 0) >> >> on this line: >> >> @contact = Contact.new(@params[:contact]) >> >> Same error (except 6 for 1) if I use: >> >> @contact = Contact.new(params[:name], params[:email], params >> [:subject], params[:message], params[:ipaddress], params[:c_date] ) >> >> Bill >> >> Ezra Zygmuntowicz wrote: >> >>> Bill- >>> You could use a Struct to make your non AR model act like an >>> Active Record. Here is a little irb session that will make this >>> hopefully more clear: >>> >> MyModel = Struct.new(:name, >>> ?> :email, :subject, :message, :ipaddress, :c_date) >>> => MyModel >>> >> @a = MyModel.new(''Jimmy'', >>> ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', ''Hello >>> World!'', ''120.0.0.1'', ''11/14/2005'') >>> => #<struct MyModel name="Jimmy", >>> email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", subject="Foo >>> Bar", message="Hello World!", ipaddress="120.0.0.1", >>> c_date="11/14/2005"> >>> >> @a.name >>> => "Jimmy" >>> >> @a.message >>> => "Hello World!" >>> So define your model like this: >>> my_model.rb >>> MyModel = Struct.new (:name, :email, :subject, :message, >>> :ipaddress, :c_date) >>> and now you can use it almost just like an Active Record in your >>> controller: >>> def create_mailer >>> @content = MyModel.new(params[:name], params[:email], params >>> [:subject], params[:message], params[:ipaddress], params[:c_date]) >>> Mailer.deliver_notification(@content) >>> end >>> Or whatever you want to use your new struct model for. Let me know >>> if this works for you. I think I understand what you are trying to >>> do and this is the way that I have been doing email only forms >>> that don''t need to have an AR model backing them. >>> Cheers- >>> -Ezra >>> On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote: >>> >>>> Yes, that''s exactly what I have in mind. Probably I''m too new but >>>> how to write the model class is confusing me, if someone could get >>>> me started that would be a big help. >>>> >>>> Bill >>>> >>>> Liquid wrote: >>>> >>>>> Hi Bill, >>>>> Is it possible just to make your model so that it does not >>>>> inherit from ActiveRecord? It would only be a volotile object, >>>>> but from what your suggesting in your email, I think this is what >>>>> your after. >>>>> eg >>>>> class Contact >>>>> I hope this is what your looking for >>>>> On 11/14/05, *Bill Lazar* >>>>> <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>>>> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>>>> Apologies because I know this has come up before but I am simply >>>>> having no luck search archives or Google other than this wiki >>>>> article: >>>>> http://wiki.rubyonrails.com/rails/pages/ >>>>> HowToUseRailsWithoutADatabase. >>>>> What I want to do is have a contact form in my app. It >>>>> doesn''t need >>>>> a db table, just the fields, but I do want to use ActionMailer to >>>>> send the messages. I generated the mailer and thought a >>>>> simple model >>>>> class, controller and form would do the trick. Controller and >>>>> form >>>>> were (if I did this right) okay but not getting anywhere with the >>>>> model. Controller has new and send_message actions, new shows the >>>>> form and send_message, which is the form''s action, calls the >>>>> generated mailer. >>>>> Could some kind soul help with the model? The fields are :name, >>>>> :email, :subject, :message, :ipaddress, :c_date (the last two are >>>>> set by :initialize in the model). >>>>> If I get this done I''ll update that wiki article with the lesson >>>>> learned. >>>>> Thanks, >>>>> Bill >>> >>> -Ezra Zygmuntowicz >>> WebMaster >>> Yakima Herald-Republic Newspaper >>> ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org >>> 509-577-7732
OK Bill- Lets turn this around then. If you just need this per request and don''t need to save anything then how about this: in your controller: def whatever Contact = Struct.new (:name, :email, :subject, :message, :ipaddress, :c_date) @contact = Contact.new(params[:name], params[:email], etc.... ) do whatever with @contact end Does that work? Without any model at all? Cheers -Ezra On Nov 13, 2005, at 7:04 PM, Bill Lazar wrote:> Thanks for the continuing help! I tried a bunch of variations, > including using the console, but all result in the same error: > undefined method `name='' for #<Contact:0x38440d8>. I know you said > to only have the Struct.new line in the model class file but I > wonder--is the controller is finding the model? > > model is app/models/contact.rb > controller is app/controllers/contact_controller.rb > > Bill > > Ezra Zygmuntowicz wrote: >> You could try it like this: >> def send_message >> @contact = Contact.new >> @contact.name = params[:name] >> @contact.email = params[:email] >> and so on... >> end >> See if that works for you. Or if you still have problems then >> fire up script/console and play with your Contact model to get a >> feel for how it works. I''m sure their is just something simple >> missing that is giving you those errors. >> Cheers- >> -Ezra >> On Nov 13, 2005, at 6:23 PM, Bill Lazar wrote: >>> Thanks for the help. I tried this suggestion but get an error still: >>> >>> wrong number of arguments (1 for 0) >>> >>> on this line: >>> >>> @contact = Contact.new(@params[:contact]) >>> >>> Same error (except 6 for 1) if I use: >>> >>> @contact = Contact.new(params[:name], params[:email], params >>> [:subject], params[:message], params[:ipaddress], params[:c_date] ) >>> >>> Bill >>> >>> Ezra Zygmuntowicz wrote: >>> >>>> Bill- >>>> You could use a Struct to make your non AR model act like >>>> an Active Record. Here is a little irb session that will make >>>> this hopefully more clear: >>>> >> MyModel = Struct.new(:name, >>>> ?> :email, :subject, :message, :ipaddress, :c_date) >>>> => MyModel >>>> >> @a = MyModel.new(''Jimmy'', ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', >>>> ''Hello World!'', ''120.0.0.1'', ''11/14/2005'') >>>> => #<struct MyModel name="Jimmy", email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", >>>> subject="Foo Bar", message="Hello World!", >>>> ipaddress="120.0.0.1", c_date="11/14/2005"> >>>> >> @a.name >>>> => "Jimmy" >>>> >> @a.message >>>> => "Hello World!" >>>> So define your model like this: >>>> my_model.rb >>>> MyModel = Struct.new >>>> (:name, :email, :subject, :message, :ipaddress, :c_date) >>>> and now you can use it almost just like an Active Record in >>>> your controller: >>>> def create_mailer >>>> @content = MyModel.new(params[:name], params[:email], params >>>> [:subject], params[:message], params[:ipaddress], params[:c_date]) >>>> Mailer.deliver_notification(@content) >>>> end >>>> Or whatever you want to use your new struct model for. Let me >>>> know if this works for you. I think I understand what you are >>>> trying to do and this is the way that I have been doing email >>>> only forms that don''t need to have an AR model backing them. >>>> Cheers- >>>> -Ezra >>>> On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote: >>>> >>>>> Yes, that''s exactly what I have in mind. Probably I''m too new >>>>> but how to write the model class is confusing me, if someone >>>>> could get me started that would be a big help. >>>>> >>>>> Bill >>>>> >>>>> Liquid wrote: >>>>> >>>>>> Hi Bill, >>>>>> Is it possible just to make your model so that it does not >>>>>> inherit from ActiveRecord? It would only be a volotile >>>>>> object, but from what your suggesting in your email, I think >>>>>> this is what your after. >>>>>> eg >>>>>> class Contact >>>>>> I hope this is what your looking for >>>>>> On 11/14/05, *Bill Lazar* <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>>>>> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>>>>> Apologies because I know this has come up before but I am >>>>>> simply >>>>>> having no luck search archives or Google other than this wiki >>>>>> article: >>>>>> http://wiki.rubyonrails.com/rails/pages/ >>>>>> HowToUseRailsWithoutADatabase. >>>>>> What I want to do is have a contact form in my app. It >>>>>> doesn''t need >>>>>> a db table, just the fields, but I do want to use >>>>>> ActionMailer to >>>>>> send the messages. I generated the mailer and thought a >>>>>> simple model >>>>>> class, controller and form would do the trick. Controller >>>>>> and form >>>>>> were (if I did this right) okay but not getting anywhere >>>>>> with the >>>>>> model. Controller has new and send_message actions, new >>>>>> shows the >>>>>> form and send_message, which is the form''s action, calls the >>>>>> generated mailer. >>>>>> Could some kind soul help with the model? The fields >>>>>> are :name, >>>>>> :email, :subject, :message, :ipaddress, :c_date (the last >>>>>> two are >>>>>> set by :initialize in the model). >>>>>> If I get this done I''ll update that wiki article with the >>>>>> lesson >>>>>> learned. >>>>>> Thanks, >>>>>> Bill >>>> >>>> -Ezra Zygmuntowicz >>>> WebMaster >>>> Yakima Herald-Republic Newspaper >>>> ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org >>>> 509-577-7732 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Ezra, Phew! Thanks so much. I finally got this up. The answer turned out to be using the correct keyword in the model class: attr_accessor :name, :email, :subject, :message, :ipaddress, :c_date I was hoping to use the model so I could include in the ActiveRecord::Validations for later. Bill Ezra Zygmuntowicz wrote:> OK Bill- > > Lets turn this around then. If you just need this per request and > don''t need to save anything then how about this: > > > in your controller: > > def whatever > Contact = Struct.new (:name, :email, :subject, :message, :ipaddress, > :c_date) > @contact = Contact.new(params[:name], params[:email], etc.... ) > do whatever with @contact > end > > Does that work? Without any model at all? > > Cheers > -Ezra > > > > On Nov 13, 2005, at 7:04 PM, Bill Lazar wrote: > >> Thanks for the continuing help! I tried a bunch of variations, >> including using the console, but all result in the same error: >> undefined method `name='' for #<Contact:0x38440d8>. I know you said to >> only have the Struct.new line in the model class file but I >> wonder--is the controller is finding the model? >> >> model is app/models/contact.rb >> controller is app/controllers/contact_controller.rb >> >> Bill >> >> Ezra Zygmuntowicz wrote: >> >>> You could try it like this: >>> def send_message >>> @contact = Contact.new >>> @contact.name = params[:name] >>> @contact.email = params[:email] >>> and so on... >>> end >>> See if that works for you. Or if you still have problems then >>> fire up script/console and play with your Contact model to get a >>> feel for how it works. I''m sure their is just something simple >>> missing that is giving you those errors. >>> Cheers- >>> -Ezra >>> On Nov 13, 2005, at 6:23 PM, Bill Lazar wrote: >>> >>>> Thanks for the help. I tried this suggestion but get an error still: >>>> >>>> wrong number of arguments (1 for 0) >>>> >>>> on this line: >>>> >>>> @contact = Contact.new(@params[:contact]) >>>> >>>> Same error (except 6 for 1) if I use: >>>> >>>> @contact = Contact.new(params[:name], params[:email], params >>>> [:subject], params[:message], params[:ipaddress], params[:c_date] ) >>>> >>>> Bill >>>> >>>> Ezra Zygmuntowicz wrote: >>>> >>>>> Bill- >>>>> You could use a Struct to make your non AR model act like an >>>>> Active Record. Here is a little irb session that will make this >>>>> hopefully more clear: >>>>> >> MyModel = Struct.new(:name, >>>>> ?> :email, :subject, :message, :ipaddress, :c_date) >>>>> => MyModel >>>>> >> @a = MyModel.new(''Jimmy'', >>>>> ''jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org'', ''Foo Bar'', ''Hello >>>>> World!'', ''120.0.0.1'', ''11/14/2005'') >>>>> => #<struct MyModel name="Jimmy", >>>>> email="jim-mcpUVnrWMFcAvxtiuMwx3w@public.gmane.org", >>>>> subject="Foo Bar", message="Hello World!", >>>>> ipaddress="120.0.0.1", c_date="11/14/2005"> >>>>> >> @a.name >>>>> => "Jimmy" >>>>> >> @a.message >>>>> => "Hello World!" >>>>> So define your model like this: >>>>> my_model.rb >>>>> MyModel = Struct.new (:name, :email, :subject, :message, >>>>> :ipaddress, :c_date) >>>>> and now you can use it almost just like an Active Record in your >>>>> controller: >>>>> def create_mailer >>>>> @content = MyModel.new(params[:name], params[:email], params >>>>> [:subject], params[:message], params[:ipaddress], params[:c_date]) >>>>> Mailer.deliver_notification(@content) >>>>> end >>>>> Or whatever you want to use your new struct model for. Let me >>>>> know if this works for you. I think I understand what you are >>>>> trying to do and this is the way that I have been doing email >>>>> only forms that don''t need to have an AR model backing them. >>>>> Cheers- >>>>> -Ezra >>>>> On Nov 13, 2005, at 3:28 PM, Bill Lazar wrote: >>>>> >>>>>> Yes, that''s exactly what I have in mind. Probably I''m too new >>>>>> but how to write the model class is confusing me, if someone >>>>>> could get me started that would be a big help. >>>>>> >>>>>> Bill >>>>>> >>>>>> Liquid wrote: >>>>>> >>>>>>> Hi Bill, >>>>>>> Is it possible just to make your model so that it does not >>>>>>> inherit from ActiveRecord? It would only be a volotile >>>>>>> object, but from what your suggesting in your email, I think >>>>>>> this is what your after. >>>>>>> eg >>>>>>> class Contact >>>>>>> I hope this is what your looking for >>>>>>> On 11/14/05, *Bill Lazar* >>>>>>> <blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org >>>>>>> <mailto:blazar-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> > wrote: >>>>>>> Apologies because I know this has come up before but I am >>>>>>> simply >>>>>>> having no luck search archives or Google other than this wiki >>>>>>> article: >>>>>>> http://wiki.rubyonrails.com/rails/pages/ >>>>>>> HowToUseRailsWithoutADatabase. >>>>>>> What I want to do is have a contact form in my app. It >>>>>>> doesn''t need >>>>>>> a db table, just the fields, but I do want to use >>>>>>> ActionMailer to >>>>>>> send the messages. I generated the mailer and thought a >>>>>>> simple model >>>>>>> class, controller and form would do the trick. Controller >>>>>>> and form >>>>>>> were (if I did this right) okay but not getting anywhere >>>>>>> with the >>>>>>> model. Controller has new and send_message actions, new >>>>>>> shows the >>>>>>> form and send_message, which is the form''s action, calls the >>>>>>> generated mailer. >>>>>>> Could some kind soul help with the model? The fields are :name, >>>>>>> :email, :subject, :message, :ipaddress, :c_date (the last >>>>>>> two are >>>>>>> set by :initialize in the model). >>>>>>> If I get this done I''ll update that wiki article with the >>>>>>> lesson >>>>>>> learned. >>>>>>> Thanks, >>>>>>> Bill >>>>> >>>>> >>>>> -Ezra Zygmuntowicz >>>>> WebMaster >>>>> Yakima Herald-Republic Newspaper >>>>> ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org >>>>> 509-577-7732