Creating new object

A newbie question here :
I don t get how to create a new object without using the magical
line : @your_object = Object.new(param[:object])

I have a grid with a size, I would like to create the case associate
to the grid at the creatin on the grid, I have try the following in
the grid controller:

def create
@grid= Grid.new(params[:grid])
((@grid.taille)-1).times do |i| //don t pay
attention to the loop, and the attribution of corrdinate, it s not a
square grid
((@grid.taille)-1).times do |j|
@case = Case.new(params[:case])
@case.x = i
@case.y = -j
@case.grid_id = @grid.id
if @case.save
flash[:notice] = ‘Case’ + i +’ ‘+ j + ’ was successfully
created.’
end
end

end

But it return an error : “wrong number of arguments (0 for 1)”
Hope you can help me.
Thx

      @case.y = -j

Probably here should be number with ‘+’. Try to take this ‘-’ before ‘j’
away.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs