No Refresh User Favorites & A Favorites Feed | Ruby On Rails

  Рет қаралды 4,937

Deanin

Deanin

Күн бұрын

Пікірлер: 31
@ryanbent9368
@ryanbent9368 6 жыл бұрын
Man, you explain Ruby on Rails concepts so well. Wish these videos were around when I first learned Rails. Keeping coming!!
@RamintaKairyte
@RamintaKairyte 4 жыл бұрын
Thank you!! You saved me! Worked perfectly! Love you man! :D I'm a newbie so it was a total life saver! NOTE to those who are using Rails 6: You need to figure out the iQuery issue (as Rails 6 does not support it anymore, but there is a way around it). Also the applications.js file in R6 is in a different location.
@fundifferent1
@fundifferent1 2 жыл бұрын
Helpful video, even though things were very out of order and back and forth, at least you went back to them. thanks
@SACSbeats
@SACSbeats 5 жыл бұрын
Great video!! Really useful thanks!
@rcg9167
@rcg9167 6 жыл бұрын
Great video. Thank you.
@olapohorecka7638
@olapohorecka7638 6 жыл бұрын
Thank you, that was very helpful!
@gerard_donnelly
@gerard_donnelly 5 жыл бұрын
Exactly what I was after. Cheers
@vladj2428
@vladj2428 3 жыл бұрын
Just in case anyone is getting the NameError in "your controller" "uninitialized constant" error If your model name has a space and you used an underscore, (for example i used "Post like" so i spelled it "Post_Likes" when generating the model ) Double check to make sure you don't add an underscore when using the class name at 3:28. EX: ``` like = Post_Like.where(post: Post.find(params[:post]), user: current_user) ``` This will throw the error. After messing around i figured that i have to write like this ``` like = PostLike.where(post: Post.find(params[:post]), user: current_user) ``` I didn't use the underscore and the second word has to be capital as well or it wont work. This isn't the only reason why this error can be thrown but it is something to check for. I'm not sure if this is common knowledge but I'm new to rails and coding in general so I didn't know and I hope it helps someone else.
@Deanin
@Deanin 3 жыл бұрын
Yeah this is some Rails specific magic that happens. I'm glad you managed to work out what was wrong! Also for someone who is new to coding in general, you did a fantastic job of sharing what the issue was and how you resolved it. Those are difficult skills for a lot of people to learn, and I just wanted to say that it does make a difference when you share this information, so thank you. Good luck on your coding adventures!
@Merrderber
@Merrderber 5 жыл бұрын
Hi there! Really great video. I have a minor problem that around 7:01 I keep getting and error that says ActiveRecord::RecordNotFound (Couldn't find Post without an ID) and am extremely confused. Any help would be great thanks!
@chuggingCoffee_
@chuggingCoffee_ 4 жыл бұрын
Try to change the param in your link_to to:
@RamintaKairyte
@RamintaKairyte 4 жыл бұрын
or try: Remove the @ and add .id ==> post.id
@prodbyindigo
@prodbyindigo 4 жыл бұрын
when I put the remote: true code in the error stays the same and says its missing the template idk what to do it creates favorite to the index show but shows the error when i click on it
@everyllm
@everyllm 4 жыл бұрын
The remote true is not working with this favorites code using rails 6 and Jquery it works if I put a redirect in the code but then it redirects so gets rid of the whole point of jquery favorite no refresh idk what I’m doing wrong
@prodbyindigo
@prodbyindigo 4 жыл бұрын
@@everyllm okay i think i figured it out I had to add require("@rails/ujs").start() to the bottom of the application.js file if anyone else has this problem
@kensanchez2064
@kensanchez2064 4 жыл бұрын
For those who needs to add an icon instead of just text(Im using material icons): *The views (shows):* favorite *update.html.erb:* $("#favorite-icon").attr("class", ""); *application Controller:* def favorite_class if @favorite_exist "material-icons-two-tone purple-icons" else "material-icons-two-tone" end end helper_method :favorite_class This took me 9 hours to figure
@PaoliPhilippe
@PaoliPhilippe Жыл бұрын
Trying to implement this feature using rails (7.0.4) works fine until min 12.00, but when we need to add the 'remote: true' on the show page this still doesn't work, anyone with the same issue?
@Deanin
@Deanin Жыл бұрын
I think most of the Rails 5 stuff will be broken in Rails 7 because they removed js.erb functionality. You might want to look into using turbo instead, which is unfortunately the preferred approach now for doing things without refreshing 🤡 Something like this might be easy enough to slot in, hopefully? kzbin.info/www/bejne/op-2e2NnmM2bfZY
@philippepaoli6904
@philippepaoli6904 Жыл бұрын
Thanks!
@christopherhurst7659
@christopherhurst7659 5 жыл бұрын
Would it be possibly if you could upload this code to your GitHub account? I am in a class for university and my team has used a lot of different variables and I am actually making a favorite's page for roller coaster database.
@fernandovargas2631
@fernandovargas2631 6 жыл бұрын
hello!! i have given this error "no such column: favorites " at line : @favorite_exists=Favorite.where(post: @post), user: current_user) please help me
@Deanin
@Deanin 6 жыл бұрын
The column does not exist error told me that one of the migrations went wrong. So after dropping my database and commenting out the line: t.references :post, foreign_key: true inside of: /db/migrate/20180609051852_create_favorites.rb I managed to almost recreate this error. It's telling me: "no such column: favorites.post_id: ..." So make sure that your migration file looks something like this: class CreateFavorites < ActiveRecord::Migration[5.2] def change create_table :favorites do |t| t.references :post, foreign_key: true t.references :user, foreign_key: true t.timestamps end end end The two t.references inside of it are important. And also watch out because the @favorites line shouldn't be @favorite_exists = Favorite.where(post: @post), user: current_user) It should be: @favorite_exists = Favorite.where(post:@post, user: current_user) You should only need one opening parenthesis, and one closing parenthesis. Hopefully this helps, if not let me know and I'll try again. :)
@basilebm
@basilebm 5 жыл бұрын
Many Thanks for this, very well explication ! One question, how to put an icon (FontAwesome) instead of text ("UnFavorite" @ "Favorite"). Should we do it into the application controller ? Many thanks
@YaroslavShmarov
@YaroslavShmarov 4 жыл бұрын
if you are using the gem 'font-awesome-saas', you can have = link_to root_path do .fa.fa-flag
@YaroslavShmarov
@YaroslavShmarov 4 жыл бұрын
example github.com/yshmarov/ror6/blob/master/app/views/static_pages/index.html.haml
@PauloVictor.17
@PauloVictor.17 5 жыл бұрын
I'm having the following error: SQLite3::SQLException: no such column: favorites.exercise I have checked everything, but I still can't find a solution
@vgfu
@vgfu 5 жыл бұрын
How do I Replace Text with an Image?
@Nellylewis
@Nellylewis 6 жыл бұрын
Hello, you did not show your routes for favorites? How do you set up them?
@rcg9167
@rcg9167 5 жыл бұрын
The update route was created when he generated the Favorites controller
@giridharan4771
@giridharan4771 6 жыл бұрын
Please post video for forgot password and exel importing and exporting....i am a beginner...
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Like button with Ruby on Rails
17:57
CJ Avilla (cjav_dev)
Рет қаралды 6 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 759 М.
Setup A Ruby on Rails 7 API With React JS
15:11
Deanin
Рет қаралды 43 М.
Rails No Refresh Like Button
18:38
LINUXANDCHILL
Рет қаралды 8 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН