How get the value user id?

Hi, all!

I'm new to RoR.
Please help me. :slight_smile:

Hi. I am also new, but I think I might get what's up. So, several
points:

1) While possible to do thing differently than Rails conventions
expect, Rails works best if you follow convention, since it assumes
you will. One issue may be that Rails' assumption is that the primary
key field of a table is called simply "id", instead of something
different like uid as in your example. If its not, you can do a
migration using rename_column to change uid to id.

2) The trick here is aligning the values from the form (those in the
params hash) and the actual Member instance to be found (maybe) using
the find method. In params you have not just a name and an email, but
(if the form is defined as such) an instance of the Member object,
even if not complete. And you can use this object to determine if its
contents identify an actual member from the database. When found, a
member will be returned as an object containing all of the member
data. If you set up your form as a view of the Member class, you
could do something like Member.find(:first, :conditions => "name
= :name and email = :email", params[:member]) when the form is
submitted. In other words, if your form is defined as a view of a
member (even if not all of the fields), it's values will be stored in
a hash that is one key , named :member, of the params hash. You can
get at specific fields of the object from params like params[:member]
[:name] if you need to, but rails is smart enough to say, "hey, I have
a member object in params, let's see if I can find a :name and :email
field" to use for my condition. Is the form a view of Member? It
should be if its fields are defined as <% form_for :member ... %>, or
some variant of that.

For those of us who come from a strict, tight-binding, declarative
world (Java, C#, SQL), this kind of loosey-goosey stuff can be
maddening. There are at least 5 other ways to do the thing you want
to do, and probably more. The trick is to figure out what "the flow"
is, and then go with it! It's not so hard to go with the flow, but I
am still working on figuring out what the flow actually is (hard,
since it's not well documented, and in significant flux at the
time :-). All I can say is, if you don't have a copy of Agile Web
Development with Rails (AWDWR), get one! It's the only source I have
found that describes, explains, and documents (not to mentioned
provides a good index for) most of what is going on in Rails.

By the way, everything I have written is my potentially flawed attempt
to translate your question into an example found in AWDWR combined
with less than a month of actual experience. So take my words with a
grain/pound of salt :slight_smile:

Tom

At first, thanks a lot!!
And I'm not good at speaking in English.
I wish you understanding, please. :wink:

I almost have programmed using PHP(not OOP).
In my memory, concept of structured programming is very natural.
It's very hard for me to program with OOP languages like java, ruby...

I think The Most Important thing is the Basic concept of it.
I'll try to study more and more about the base knowledge about Ruby
and RoR.

Thanks, again.
Rucy.