Activity
Posted in Dynamic Active Record Associations?
I would definitely consider it a code smell. The good thing is that if you are using it, you already have a join table and you can just create a new model file to represent it and swap your associations out.
It's usually pretty easy to swap out the associations because you'll basically use the same options only this time it has a defined Rails model for the join table instead of it being generated inside Rails at runtime.
Posted in Dynamic Active Record Associations?
I'd follow Bob's advice on this one. I was going to suggest the same thing. The main problem with has_and_belongs_to_many
is that it doesn't let you access the join record easily so you need to swap it with an actual model named like EventPrice and do the has_many
and belongs_to
with that model.
Thanks for the tip! I was wondering how long Github would allow people to use their assets.
I skipped a few of those pieces to focus on the topic in this episode. The controller and views are basically just those you get from generating a scaffold.
In the future, I'll be sure to include the code for you in between.
Looks like I'll need to amend this episode. Thanks for the heads up!
Glad you're enjoying it Matt! :) Hit me up if you have any ideas for screencasts or ways to improve the site!
If there are things like legal reasons why you should separate out the DBs, then it's good to, otherwise it's often just a lot more work and much harder to maintain. You're probably best off doing without multiple databases unless you know you need that feature. Of course, that means that every record should be linked to an some sort of Account model if you don't have separation through database.
Reply would be a database model somewhere with a "state" attribute. I didn't include that part here because I didn't have the full code to begin with. You can assume it's used to keep track of the conversation and what "state" it currently is in.
Posted in Radio buttons as actual buttons
Yes definitely would if you're using something that doesn't have it built-in.
Ah yes! I'll have to do an episode on that too.
If you pass the same parameters to the URL as the HTML form that gets generated it will work. Of course, you will need to make sure the mobile user has a way to authenticate as a user for that request by setting a cookie or using an API token. Mobile apps talking to a Rails app are basically the same as your browser, you just have to worry about things like cookies/API tokens.
I don't think you can with ActiveRecord since you need a database migration to add it. That's a great point for MongoDB users though! Super simple.
Posted in File Uploads with Refile Discussion
I did forget to include that. It's an awesome little feature along with deleting uploads. It definitely still is pretty new and you can do everything with Carrierwave no problem.
That could definitely give errors when nginx tries to serve them up. One thing you can do is change the nginx user to deploy. I often do that so I don't have to worry about accidentally messing up www-data ownership when I deploy.
Yeah whoops. Redcarpet doesn't do well with it apparently. Updated.
Interesting. Those should not be hitting Rails.
Maybe try this instead of the location block:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name xxx;
passenger_enabled on;
rails_env production;
root /home/deploy/xxx/current/public;
error_page 500 502 503 504 /500.html;
}
Those should automatically get served up. Can you post your config? Anything in your logs that doesn't look right?
Posted in Radio buttons as actual buttons
The Bootstrap code should actually check the radio buttons for you. You don't need to use a hidden field because with radio buttons, you set the same name for the different inputs and the browser submits only the value of the checked one. Does that make sense?
Posted in Build REST API with Devise
I think you can just simply make a POST to the same url as the sign up form normally which is /users
. Same with PUT and DELETE but for logging in and out, you want to POST and DELETE to /sessions
because that's a separate controller.
As long as you can calculate the percentage, all you need is some CSS. Bootstrap ships with a progress bar and all you need to do is set the width to the percentage complete. http://getbootstrap.com/com...
You can find many others if you're not using Bootstrap and you just google "css progress bar"