Getting specific values from params

Sorry to post two newbie questions in one day :slight_smile:

I’m trying to make a new Character row in my database. It has several
values in the row, but I only need 2 or so from the user and the rest
can be figured out by the app. My problem is I’m having trouble
figuring out how to get a specific value from params.

For the record, I’m still in Rails 1.2.6.

So the form for the Character object should gather the Character’s
codename, as well as the Character’s Power Level.

I want to gather the two paramters, do some calculations, and then
actually do the creation, rather than having the user hard code all
the values in a form and doing mass assignment.

So, the form I have now looks like this:
<% form_tag(:action => ‘create’) do %>
<%= text_field ‘character’, ‘codename’ %>
<%= text_field ‘character’, ‘power_level’ %>
<%= submit_tag “Create Character” %>
<% end %>

I expect my create method will contain something like this:
character = Character.new do |c|
c.codename = [Codename Parameter]
c.power_level = [Powerlevel Parameter]
c.power_points = [Powerlevel Parameter * 15]

end

However, I can’t figure out how to retrieve the individual values
brought over from the form.

I just thought that I might be overthinking it, and I would be able to
do:
character = params[:character]
@codename = character.codename

But when I tried to print out @codename in a temporary view, it gave
me an error for calling an undefined method.

Nevermind, I think I have it.

params[:character].fetch(‘codename’)

Seems to look right.