AppDev Week 3
javascript!
Always include jQuery when using javascript
be sure to put the jQuery script as the first element before the script
Be careful of javascript asynchronous movement
Many things operate in parallel so be mindful of the code
To stuff like toggle in a function to help
callback functions
jQuery documentation is great
hover above a link is called a tooltip
put tooltips on the bottom of application layout for best effect. if on top, it will error because it runs before the html runs
better is to use $(document).ready(function(){ put in here}) in the head of the application layout
%i is used for creating an array of symbols
regular expressions are a pattern matching language
checks a string against a certain pattern
Pundit has makes sure you get the authorization correct to hide or show parts of the page, theres a chapter on it
policies folders has a place where we can define methods
becomes the one place where we make the policy on who does what
font awesome is a font set that we use for the discover nav bar
validates :recipient_id, uniqueness: { scope: :sender_id, message: "already requested" }
validate :users_cant_follow_themselves
def users_cant_follow_themselves
if sender_id == recipient_id
errors.add(:sender_id, "can't follow themselves")
end
end
validate is used when wanting to define our own method for validation
I18n is a class where the purpose is to automatically translate our old app into new languages for different users, multiple languages, make a key and then it changes the language, pulled from devise
dom_id is a helper function that simplifies class name and id number into one string
strip_attributes gem is used for setting parameters for user inputs commands like username creation with no white space etc
- add remote: true to link_to functions to break the link
- add a response in my respond_to block
- update the template with the responses I want
escape_javascript method
Top comments (0)