Nested Form Complex Structures

Hi,

controller

form

fieldset

form view

As in the above picture only typing groupName groupName value written I want to be written for each attrib. Is it possible. I would be grateful if you can help.

Help me please

I am my fault for using Ruby on Rails

I understand that English is not your native language. It’s ok. But it’s really hard to understand what is the problem.

Maybe try to wite what the problem is in most simple words. You can always write it really simple in your native language and use google translate.

I really don’t try to offend you. I just want to help. We can’t help you, because we don’t understand what do you want, and not because we don’t want to.

Form Photo

Hello
I’m very sorry for translation.

I am sending a photo. In this, as in the photo, the table next to each line separately attributes and the group name will be in all the rows.

Please check carefully the photo. this old table and not subject to change.

Thank you.

Show us Radgroup Model

class Radgroup < ActiveRecord::Base
has_many :radgroupchecks
accepts_nested_attributes_for :radgroupchecks, allow_destroy: true
end

class Radgroupcheck < ActiveRecord::Base
belongs_to :radgroup
end

Codes in me is not so important, I may have made a mistake. I actually want to form pictures, wherein the table and should be on columns. It can also be performed using a single model

Users must write to separate line for each attribute a time when the group name. FreeRadius SQL schema statements can not intervene because it is in this way.

Controller:

def create
    radgroup1 = Radgroup.new(groupname: radgroup_params[:groupname],
                             attribute: "MaxTimeLimit",
                             op:        ":=",
                             value:     radgroup_params[:time])

    radgroup2 = Radgroup.new(groupname: radgroup_params[:groupname],
                             attribute: "MaxDownLimit",
                             op:        ":=",
                             value:     radgroup_params[:downlimit])

    radgroup3 = Radgroup.new(groupname: radgroup_params[:groupname],
                             attribute: "MaxUpLimit",
                             op:        ":=",
                             value:     radgroup_params[:uplimit])

    respond_to do |format|
        if radgroup1.save && radgroup2.save && radgroup3.save
            ....
            ....
        else
            ....
            ....

And here is form:

<%= form_tag "/radgroup_controller/create" do %>
  <%= text_field_tag "groupname", "default info" %>
  <%= text_field_tag "time", "default info" %>
  <%= text_field_tag "downlimit", "default info" %>
  <%= text_field_tag "uplimit", "default info" %>
  <%= submit_tag "Save" %>
<% end %>

That is how i would probably do it. Or at least something in this direction.

1 Like

You are super.

but the problem was in route. What can I do.

Problem Link

Try this:

<%= form_tag "/radgroups" do %>
  <%= text_field_tag "groupname", "default info" %>
  <%= text_field_tag "time", "default info" %>
  <%= text_field_tag "downlimit", "default info" %>
  <%= text_field_tag "uplimit", "default info" %>
  <%= submit_tag "Save" %>
<% end %>

form_tag __PATH__ do here path must be correct one for your site. http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag

Permit Problem

params.require(:radgroup).permit(:groupname, :attribu, :op, :value, :time, :downlimit, :uplimit)

I tried it but it did not

I think it should be without :radgroup, like this
params.permit(:groupname, :attribu, :op, :value, :time, :downlimit, :uplimit)

unfortunately it did not happen. If you give your e-mail address I can give my nitrous information, you want to look

I’m giving you a lot of trouble, I know

Let’s write in the forum but please fix solution you

Can you share your code on github?

I would ride the train in fear of iron

https://www.nitrous.io/

username emrah
password 159753

example-rails open idle
cd /code/testo
rails s -b 0.0.0.0 priview

I love people. :slight_smile:

Tanks

I have here during weekend very bad internet connection. Can’t really work online.
But from what I saw, you are making form dynamically, using JavaScript, and because of that names of fields are not the same as names of parameters here params.require(:radgroup).permit(....)

You have to make sure that form fields have the same name as parameters, and use those names from form in the controller.

OK

I made a few attempts. If the authors of the forum. Without the internet it improves when we look?

I will try to look at it, when i’m home on monday afternoon.

When you want to connect to me you’re a writer.

thank you so much

Hello

Rails attribute column name for his own use, I changed the column name and did attribu. Even though I get the error making records in the database. This is very good.

editor does. one is done in one deletion.

I’m getting too much of your time
If you have time please look at an empty outside of work

thank you so much.