Craig Hoffman

Joined

940 Experience
1 Lesson Completed
1 Question Solved

Activity

Posted in Best Approach for Updating Attributes On Join Table

I have a view (show) that display's an Article. The Article has several Author[s]. The Article and Author models look like this:

Associations:

Article Model
has_many author_articles
has_many articles,  through: :author_articles 

Author Model
has_many author_articles
has_many author,  through: :author_articles 

AuthorArticle Model
belongs_to article
belongs_to author

The join table (AuthorArticle) contains an article, author id columns, and another column called position_id. The Position model is also a has_many through. It looks like this:

Associations:

Position Model
has_many author_articles
has_many positions,  through: :author_articles 

Author Model
has_many author_articles
has_many author,  through: :author_articles 

AuthorArticle Model
belongs_to article
belongs_to author
belongs_to position

Here's what I would like to do and I am not exactly sure how to implement it. I would like to click on the author's name from the article show view, open a modal (already done) and have a form (SimpleForm) where the user can select a position (first, second, third, etc...) and press submit. The order of the author is important. Yes, there can be several "first/lead" authors. The form post would update the join table (AuthorArticle) position_id column with the position selected. Authors are added when a new article is created or updated.

Does this make sense? Let me know if you need more context? Something doesn't feel right about this approach and I'm open to suggestions/feedback/ideas.

Thanks!

Posted in How do I configure Rails to use a Proxy URL

Let's say we have a Rails project operating on the domain https://hello.world.com. The way the organization's infrastructure is set up, https://hello.world.com gets proxied into a new URL called - https://my.companies.server.com/hello . When I start the server with Rails s -e production and navigate my browser to https://my.companies.server.com/hello, all the CSS, assets, JS is broken. After some research I changed this config:
config.action_controller.asset_host = 'http://hello.world.com' and the CSS, JS, and assets seem to be working again. Great. One thing that's certainly not right is the links / main navigation (routes). For example, when navigating to any page in the browser, for example, https://my.companies.server.com/about, I get a 404. Seems like there should be a "pass-through" when a request comes in it gets mapped it to https://hello.world/about? Does this make sense? I could use some assistance. What's the best approach here?

My Setup
Rails 6.x.x
Ruby 2.7.x
Nginx

Thanks!

I would like to get everyone's take on what are is the best practice for storing DB usernames/passwords, API keys, Contstants, Etc... Should they be stored in config/environments/ then in test, development production accordingly? Some of these files do end up in verstion control. Thoughts?

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.