You’re not receiving notifications from this thread.
@Mentions, Autocomplete, Notifications, and Links | GoRails - GoRails
This is cool. Although, when you said 'notifications' I was expecting in-app notifications not an email notification. I was wondering how you were going to cover so much material in 1 episode, but now that I realize it was just a brief email notification, I understand.
I would modify the title and description to just focus on @Mentions and Autocomplete, with a sprinkle of notifications and links added in.
Otherwise, awesome stuff.
Chris, great stuff, thanks. Note that \w in a regex *is* a character class, so it does not need to be enclosed in the [ ] brackets if it's by itself. So /@(\w+)/ is all you need. Also, this would need some tweaking to avoid matching the domain name of an email address, for example. (html-pipeline's version does this)
Great episode! Learn few tricks there.
I'm not is there any way to use At.js to support what is similar to facebook mention, it means it will use display name instead of unique field, but I think they keep either id or username in local values there.
You might be able to, I'm not entirely sure. The full names make it more complicated.
You can inspect the HTML on Facebook to get an idea of how they do it. They have a much more complex system for it as you'll see with their "highlighter" class right above the textarea. Rather that doing much of this in text, they handle much of it in the JS instead so they can do more complex things. An out-of-the-box JS library like at.js won't be able to compete with that.
I found a gotcha to be aware for everyone who is/were watching this episode. When upon calling @mention into the post and click on the referenced username, it will return a invalid number ID instead of the username ID.
I made some changes to the User controller ruby code. To get your username referenced in the URL like /users/yourusernamehere, you will need to the following changes:
In your db/migrate/[datetime-stamp]_create_users.rb:
line 4: create_table :user, id: false do # add this id method into your file before migrating
[new line] line 2: self.primary = 'username'
resources :users, param: :username # add this line as well.
User.find(params[:username]) # alter :id with username
And that should work for everyone! (p.s: you will need to reset your database if you migrated before aka rake db:reset)
hi @excid3:disqus on the @mentions episode can you share the css you use to show both user name and profile picture?
Hey Chris,I don't have a Users Controller.I am using devise so i have a registrations controller
class RegistrationsController < Devise::RegistrationsController
params.require(:user).permit(:email, :user_name, :full_name, :password, :password_confirmation)
params.require(:user).permit(:email, :user_name, :password, :password_confirmation, :current_password)
I added an index action and created an index.json.builder but when i navigate to /registrations.json i get an error
So how do i get json file.
You can still create a users controller even if you use Devise so you can make the /users.json endpoint. Devise doesn't define a GET route for /users, just POST and PUT which means you're free to create one or you can make a different route as well.