Nested Form Complex Structures

I cloned your repo, and looked at the code, but I didn’t wrote anything yet, I’ll should write something tomorrow and I let you know.

https://github.com/sztosz/radgroup here you have working app with one model form

http://railscasts.com/episodes/196-nested-model-form-part-1?view=asciicast here you have tutorial how to add multiple model forms on one page.

https://rbudiharso.wordpress.com/2010/07/07/dynamically-add-and-remove-input-field-in-rails-without-javascript/ and here is example how to dynamically add more forms to one page.

I’m sorry for not answering earlier, but i have a lot of going on in my life, and very little free time.

it must have been for a long time, it seems you’ve forgotten where we stayed. You start from scratch, but it’s not like I want to, you wrote code already gives scaffold. You got a hand you already form. We had a problem index and editor. In the link you sent, they do this process using two table and I looked at them before. Due to the nature of FreeRadius table, two table nested forms are not useful to us.


The image editor has the index and shape. I would like to examine.

I know I take your time, and I’m sorry for it.

I think I don’t really understand what you need. In create(?), index, and edit you have “Group Name, Time, Download, Upload”, and in the destroy you have “Group Name, Attribute, Op, Value” I really don’t know how the correlate. Are those two data structures?

Do you wan’t exactly something like this: http://pasteboard.co/1cPYw2wA.jpg ? And if so, Why structure in database is so different from what you have in form?

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 %>

These codes worked very well. The only problem index view, edit and delete.

I want it in the form http://pasteboard.co/1cPYw2wA.jpg And you do it, so here is working very smoothly.

The index also want it http://pasteboard.co/1npWPpGw.jpg and Regulations.
so I want to appea are in one line.

This database structure is completely absurd of freeradius.org
http://wiki.freeradius.org/config/MS-SQL-DDL-script

Hi Bartosz

Is it something to do? What do you think you will be able to? I think no one can do if you can not do it.

Hi.
I have a question. I have many to many through relation between Training and Exercise with indirect TrainingExercise. In Exercise model I have only exercises (frozen I would like to be). On the simple form I would like choose few exercises from particular scopes, date for Training and save it, but not to Exercise, just to indirect model TrainingExercise (:exercise_id, :training_id), and Training(:date). Juts save into only these two models. I use nested_attributtes, forms, but it does not work for me. Has anyone any idea how solve this ? THX.

Hello there,

You’re kidding. This request burasıda my place. So you make your shame, indiscretion.
You can open a topic about it. We also have a saying Turkey; two people talking, falls third crap food

I think I understand now clearly what you need. You want to control freeradius, and since it have database structure you can’t modify you have to make all necessary model transformations from nice and readable Business Model to Database Model, back and forth.

I’m having really lot of going on in my life now, but if you are willing to wait, I will try to write something by the end of the week. But please feel free to search for help in other places, as I really can’t promise anything. But it will be nice exercise so I’ll do it anyway :wink:

thank you so much. I can wait
you are a very good person
I hope you have a very successful life

I created new github repository, it’s based on new Rails 5. But don’t worry about rails 5, you can do same with Rails 4

First, download it, install (bundle, rails db:create. rails db:migrate etc) and play a bit

I changed some names, for exmaple i used :atrr instead of :attrubu, but you can change it if you wish, so it will work with your radius correctly.

You can create and edit new groups, and it translate correctly to the database schema. The file that is most important for you is radgroup/app/view_models/form_model.rb Maybe tt’s not the best way to it, but it’s simple and quite readable.

I didn’t do destroy method. But if look at save and find method you should be able to do it on your own, it’s an exercise for you :wink:

There is one line that can be hard to understand at first

form_models[group.groupname].send("#{group.attr.to_s}=" , group.value)

here you can read about Ruby send method with examples:
http://ruby-doc.org/core-2.3.1/Object.html#method-i-send

If you won’t be able to understand it, don’t be shy, say it, and I’ll rewrite it for you with if, and else. Really, send can be a little hard to understand at first.

I’m also not using :id but :slug. Slug is :groupame without special characters and spaces, that can safely be entered into browser address bar. In your database radgcheckgroups all have different id, but they have same :groupname for one group, so by using:groupame to find them we don’t have to track all id’s across the application. As I wrote, it’s not the best solution, but it works, beside my answer is only to guide you, and not do all your job for you :wink:

I really hope i understood what you need :slight_smile:

Bartosz greetings,

I told you to write code. You wrote poetry. :slight_smile:

Are you developer? Are you a poet? :slight_smile:

It would not write perfect code. I was surprised how to thank you.

You’ve finished the event as a developer.

I use thanks to you rails5 :wink:

There is a small error; edit made on the index page, I change the group name, creating a new group.

Finally, I’ve had a problem with the structure FreeRadius. I would be grateful to you if you do that. I tried, but I could not. :blush:

My problem is that; rad_check model from the model data will be collected in rad_group_check rad_user_grup model.

I tried to use colletion_select, but did not succeed. rails5 uniq does not want to use. They’il completely remove the rails5.1. Instead of “distinct” I used. But I was not successful. Data came, but did not register.

I want exactly that, I hope these pictures will tell you what I want

rad check and rad user group photo

You can examine what I did last

https://github.com/emrahyildirim/radgroup

Please help me. He could not tell me no one else. I can not thank you how. :blush:

time = RadCheckGroup.where(groupname: slug.humanize, attribu: :time_limit).first || RadCheckGroup.new(groupname: slug.humanize, op: ‘:=’, attribu: :time_limit)

example
It works in this way
time = RadCheckGroup.where(groupname: slug.humanize, attribu: :time_limit).first || RadCheckGroup.new(groupname: slug.humanize, op: ‘:=’, attribu: ‘Cleartext-Password’)

Example Attribute ‘Cleartext-Password’

I could add to the attribute with the line in the middle way. Could you please look at this, I can not do it. FreeRadius made using atrribut line in the middle, such that -

dude what’s up,

Did you see what you did?

respects

I don’t have time to write this app, really. I wanted to help you, but I can’t write it all for you.

As for that attribute name, look at first this line
attr_accessor :name, :time_limit, :download_limit, :upload_limit, :slug
in app/view_models/form_model.rb

You have to define there what attribute you want to pass from form to the model.

Hi Bartosz

I want to help the last time. The latest crux of the business. If you do that, I would really appreciate it. I already GitHub 'can also examine the link and I took the photo. There’s no hurry, would Grande look at spare time, please. very confused, I do not get the results I wanted what I did. You are the only one who understands me, please.

good morning brother

You will care for the last time right?

Good work

I don’t have time to write apps in rails for you :frowning: If it was a little, small help I would help you. But you need someone to write an app for you. Either you will learn to do this by yourself, or you have to hire someone to write this app for you.

Hello Bartosz

First, I think me wrong. I’m trying to do something on a FreeRadius database is non-standard, and I am trying to do with Ruby on Rails. This is not a project for me, just to force me to learn and is an educational tool that will allow me to go on. Of course, I am forced to get help in place, an indication of the reason for the existence of the forum. For this, I could have gone too far in the direction of your sincerity and I would have moved out of the forum, I am very sorry for it.

Thank you.
Respects.

I can not do this, it can not be with the top line of the attribute. Can you help me? I tried to do with attr_accoss but I could not.

I’m glad you can do it for one, for example: for time_limit instead Cleartext-Password

Thank you.