ruby on rails - Is form data passed through session or params? -


i not understanding difference between session , params in following application.

a user submits new movie form. how associated controller access title of movie?

  1. session['title']
  2. session.title
  3. params['title']
  4. params.title
  5. all of above

based on stackoverflow answer @ difference between session , params in controller class:

params live in url or in post body of form, vanishes query made.

session persists between multiple requests (the info stored in cookies depends on configuration).

to short:

  • params: 1 request (creation of 1 object, access 1 particular page)
  • session: info persisted (cart, logged user..)

i chose (1) session ['title'] on quiz , got answer wrong. chose (1) because thought involved accessing information had persist.

am misinterpreting question , maybe falls more under "one request only" answer should (3) params['title']?

to attempt answer question in context of quiz instead of in context of code, consider says that:

params live in url or in post body of form, vanishes query made.

now consider question says:

a user submits new movie form. how associated controller access title of movie?

so question saying user interacts filling out form posted server. "post body of form" mentioned in notes.

so correct answer 3) params['title'].

now, once data accessed, can placed session, that's developer or decide, , that's not within scope of what's being talked here.

you know that, in context of question, session not what's used because question refers single request: sending of form. if question referred data sent form had persist on few more requests (such multi-page form), session might come play.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -