Hello, I am creating a management system and used scaffolding to create the setup for the admin portion. I have it linked to an Account database, and the new account form is filled with the fields from the database. Some of the fields in the database are not meant for the user to fill in but the system itself when the record is processed. What is the best way of going about making those fields invisible to the form? Basically, I need the system to input data to those records as needed. Thanks! Sincerely, Michael Novak --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Scaffolding in Rails 1.1.6 is very rudimentary. For beginners it is better to stay away from it. Rails 1.2 RC1 scaffolding is much better and you can use it as a good start for your project. In 1.1.6, the view uses reflection to iterate through all the fields in the database, so you must change it to display only the fields that you want to be visible to the user. You have to use tags for each field that will generate the html elements. Look at the docs at http://api.rubyonrails.orgfor more details. On 12/13/06, Mike <michaelrnovakjr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hello, > I am creating a management system and used scaffolding to create > the setup for the admin portion. I have it linked to an Account >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike wrote:> Hello, > I am creating a management system and used scaffolding to create > the setup for the admin portion.Scaffolding is really just example code, not intended for production. Like the word scaffolding implies, it''s meant to be temporary while you get your application up and running. Get a Rails book like Agile Web Development with Rails (pragprog.com) - the 2nd edition is supposed to ship any day now. It''s a great book for someone new to Rails. I also really liked Ruby for Rails by David A. Black (www.manning.com/black) as well, as it focuses a bit more on the Ruby language while still giving you the fundamentals of solid Rails programming. Jeff softiesonrails.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You have two options: 1) use hidden fields 2) remove the field from the view completely and fill them in in your controller create action. For example: JUST SAVE DATA FROM FORM: @person = Person.new(params[:person]) if @person.save ADD SOME OTHER STUFF: @person = Person.new(params[:person]) @person.agreed_to_disclaimer_at = Time.now @person.languages = params[:person][:l1] + params[:person][:l2] if @person.save -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/13/06, Mike <michaelrnovakjr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am creating a management system and used scaffolding to create > the setup for the admin portion. I have it linked to an Account > database, and the new account form is filled with the fields from the > database. Some of the fields in the database are not meant for the > user to fill in but the system itself when the record is processed. > What is the best way of going about making those fields invisible to > the form? Basically, I need the system to input data to those records > as needed.The Scaffolding Extensions plugin [1] can do that. Jeremy [1] http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
As others have said, scaffolding gives you a starting point and you will very quickly out grow it. I would suggest building your own forms and methods to handle the fields, but stay away from hidden fields (they are too easily hacked). You will learn more about how Rails work and become more secure and productive in the process. Also, if the fields are super sensitive, check out attr_protected (http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000873) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I recently started playing with ajax_scaffold and it''s pretty impressive. One thing I noticed, was that any field containing "_id") was not shown in the scaffold GUI. For example, I appled the scaffold to a table which had the following fields: "id", "person_id", "attribute", "value" In the scaffold GUI, all that was shown was "attribute" and "value". I agree that building your own CRUD interface is best but.. if you''re even remotely as lazy as I am, you could just suffix a field with "_id" and it *might* be hidden. Check it out @ http://www.ajaxscaffold.com... setup was exteremely easy: gem install ajax_scaffold_generator ruby script/generate ajax_scaffold Attrubute ##for table named attributes --then open http://<server>:<port>/attributes :-) Good luck On 12/13/06, askegg <andrew.skegg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > As others have said, scaffolding gives you a starting point and you > will very quickly out grow it. > > I would suggest building your own forms and methods to handle the > fields, but stay away from hidden fields (they are too easily hacked). > You will learn more about how Rails work and become more secure and > productive in the process. > > Also, if the fields are super sensitive, check out attr_protected > (http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000873) > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It''s a nice GUI. I think it hides the id fields because these are basically glue to hold the tables together. Ajaxscaffold still gives you way to add associated information to models (I think). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ya... right now, I have an images table with blob images. --would be nice if scaffolding interpreted the content/type and rendered gifs/jpegs/pngs automatically :-) and "new" or "edit" gave me the "file / upload" option :-) On 12/13/06, askegg <andrew.skegg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > It''s a nice GUI. I think it hides the id fields because these are > basically glue to hold the tables together. Ajaxscaffold still gives > you way to add associated information to models (I think). > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
New ajax_scaffold version 4.0 does support _id, and even realizes if there has_many, belongs_to, habtm associations so you can show them by default or redefine representation for each and any controllers and fields in that controller, as well as way more points of configuration. This version is a major redesign of the plugin. You will see it yourself soon. Keep tuned for ASp. :) All the Best! Sergey. Ajax_scaffold junior developer :) x1 wrote:> I recently started playing with ajax_scaffold and it''s pretty > impressive. One thing I noticed, was that any field containing "_id") > was not shown in the scaffold GUI. > > For example, I appled the scaffold to a table which had the following fields: > "id", "person_id", "attribute", "value" > > In the scaffold GUI, all that was shown was "attribute" and "value". > > I agree that building your own CRUD interface is best but.. if you''re > even remotely as lazy as I am, you could just suffix a field with > "_id" and it *might* be hidden. > > > Check it out @ http://www.ajaxscaffold.com... setup was exteremely easy: > > gem install ajax_scaffold_generator > ruby script/generate ajax_scaffold Attrubute ##for table named attributes > > --then open http://<server>:<port>/attributes :-) > > Good luck > > > > > On 12/13/06, askegg <andrew.skegg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> As others have said, scaffolding gives you a starting point and you >> will very quickly out grow it. >> >> I would suggest building your own forms and methods to handle the >> fields, but stay away from hidden fields (they are too easily hacked). >> You will learn more about how Rails work and become more secure and >> productive in the process. >> >> Also, if the fields are super sensitive, check out attr_protected >> (http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000873) >> >> >> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I cant wait! On 12/13/06, Sergey Kuznetsov <rails-9a/WvBvX2Qpg9hUCZPvPmw@public.gmane.org> wrote:> > New ajax_scaffold version 4.0 does support _id, and even realizes if > there has_many, belongs_to, habtm > associations so you can show them by default or redefine representation > for each and any controllers and > fields in that controller, as well as way more points of configuration. > > This version is a major redesign of the plugin. You will see it yourself > soon. > > Keep tuned for ASp. :) > > All the Best! > Sergey. > Ajax_scaffold junior developer :) > > x1 wrote: > > I recently started playing with ajax_scaffold and it''s pretty > > impressive. One thing I noticed, was that any field containing "_id") > > was not shown in the scaffold GUI. > > > > For example, I appled the scaffold to a table which had the following fields: > > "id", "person_id", "attribute", "value" > > > > In the scaffold GUI, all that was shown was "attribute" and "value". > > > > I agree that building your own CRUD interface is best but.. if you''re > > even remotely as lazy as I am, you could just suffix a field with > > "_id" and it *might* be hidden. > > > > > > Check it out @ http://www.ajaxscaffold.com... setup was exteremely easy: > > > > gem install ajax_scaffold_generator > > ruby script/generate ajax_scaffold Attrubute ##for table named attributes > > > > --then open http://<server>:<port>/attributes :-) > > > > Good luck > > > > > > > > > > On 12/13/06, askegg <andrew.skegg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> As others have said, scaffolding gives you a starting point and you > >> will very quickly out grow it. > >> > >> I would suggest building your own forms and methods to handle the > >> fields, but stay away from hidden fields (they are too easily hacked). > >> You will learn more about how Rails work and become more secure and > >> productive in the process. > >> > >> Also, if the fields are super sensitive, check out attr_protected > >> (http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000873) > >> > >> > >> > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---