Symbols vs Strings Discussion
Nice! Some of my upper division CS students struggle with the notion of symbols, and I'll point them this way.
Organising large rails apps is something that I struggle with. I've look at namespacing models but can never get my head around the folder structure and then the different way you have to reference a model in a namespace or scope.
Because of this I avoid it and end up with 50 models in one folder.
I'd be very happy for you to explain how to do this better?
Hey Rob - I could give you some pointers on that kind of thing. Are you in the slack channel where I could DM you? - David
Great video Chris. Would love to see one on relationships such as has_many :through and Polymorphic.
This is a very great episode because help me understand what's happeing under the hood. What I didn't know and I haven't hear before was what you mention at 7:18:
the last set of arguments to any function can be a hash and you don't have to specify the curly braces, they're optional
I have used that in my methods but I've never new that this could be the last argument for any function. Do you have any source to read more about this topic?
I'm still finding this a bit confusing because it seems like you're comparing apples to orange. The way I see it, which is why Im' confused is that a symbol represents something.
Like the :set_project
symbol. It represents/contains the method that was defines. Where
Project was successfully created
is a string and what is being represented by the notice: symbol. Am I understanding this wrong. Please clarify when you get the chance.
This was my understanding too. A symbol (the way I was thinking of it) is more like a variable name, whereas a string is a rendering or a value.
Amazing video!! Thank you so much Chris for these basic/general courses - more of these would be incredile!
So the confusion that I have around all this is where is the link between before_action :set_project
and def set_project
? Like how does it know that the symbol :set_project is referring to the method set_project defined elsewhere?
@chris, it looks like you have some bots getting into your comment section. Maybe add a video how you would try to stop this?
I've had the same stuff on my bigger websites. Even after the captcha and invisible honeypots didn't help, I created a validate action that checks for forbidden keywords in the posted comment and try to block them off this way...
After that some bots still got in. What I did then was check if a user was logged in during the post of the comment. If not, the comment would have to be approved by a moderator. Until now (about 6 months) no spam got to any of my customers, and I refused about 20 comments.