Giter Site home page Giter Site logo

Comments (3)

russellquinn avatar russellquinn commented on June 18, 2024

Should you be using collection_select instead?

http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select

from casein.

russellquinn avatar russellquinn commented on June 18, 2024

This is how I've used casein_select for one-to-one relationships before. I can't see any reason why multiple wouldn't be passed through. If you're able to share your project with me, I can take a look.

<%= casein_select f, f.object, :column, Column.order(:title).collect {|c| [c.title.titlecase, c.id]}, {:include_blank => '-- None --', :casein_label => "Choose an existing column"} %>

As for other advice: in general, you can use the form partials directly for nested attributes:

<%= f.fields_for :column do |column_form| %>
    <%= render :partial => 'casein/columns/form', :locals => { :f => column_form } %>
<% end %>

Casein's support for relationships in the scaffolding isn't great, but when not using nested attributes, I usually scaffold out the child models using the --no-index option (this stops it being added to the tabbed navigation, removes the unneeded controller methods, limits the appropriate routes, etc.) which will generate all the view partials. Then I add render the child's _index partial at the bottom of the parent's show view, plus I add a button to create a new child object into the sidebar of the parent's show view. It requires a little copying and pasting, but you can quickly build up the views.

Getting better automated support for relationships in the scaffolder would be great though β€” I just don't have time right now, but I'm always looking for help to expand the project ;)

from casein.

chelseakomlo avatar chelseakomlo commented on June 18, 2024

Thanks so much for the help, and the quick reply! Much appreciated! I got the form to render- still working through a few things but overall everything makes sense. We all really like how straighforward/lightweight Casein is.

If we end up using Casein in our project, we'll definitely look into helping with the scaffolding for relationships :) Thanks so much for making this project open source!

from casein.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.