I want easy implement a show hide funktion on sertant fields. Like birthday or email for a user. Example if the user has chosen to hide his email it wont display in his profile.
How do i create this?
Best regards,
A Rails (3) beginner
One option would be creating a model to store user preferences in to keep track of what the user wants to show/hide. Another option is to use one of the gems out there that will help you accomplish this task.
Just looking on github, I came across https://github.com/pluginaweek/preferences.
Related
I have been trying to solve a problem for some time in ruby on rails, but I haven't been able to achieve it and I can't seem to find a solution online (it must be easy but I am not sure what is the write thing to search for)
So, in my web application, I have a CURD table and I use modal to create new items in there:
Image 1
Image 2
This is working perfectly fine. What I would like to do is that when this is created I'd like to post in a different page that " ABC have been created by X User"
In my case that would be the chatbox container:
Image 3
So in my case, the green box is where I would like to say of what has been created and who has created it. I know that it is not a complex problem but I just can't seem to find the solution and I have been trying this for days.
Would really appreciate your help. Please let me know if you don't understand the problem and I can elaborate.
Thanks in advance.
Kind Regards,
Usman
You can create a separate model Notification (or similar name), and use an after_create hook in your original model to automatically create an instance of Notification. The Notification could store the information you want to display as attributes. From there, you'd have to figure out how to display the notification in the correct place on the 3rd page. One approach would be to query all your posts and notifications and sort them by created_at. There's other ways, it's up to you.
I get what you're saying.. but I am a little confused on the first part. So I have a model called Solr that has all the records associated with its User. What do I put in the after_create hook method to display records according to the timestamp in my Chat Box/ Events Log? Do you have an example of a similar implementation?
PS - Why do you say that I need to create a new model why can't I use the same model?
Thanks.
I am using a jira mail handler to automatically create tickets whenever email comes to a particular mail id. However many of the users who are sending mails are part of jira users and jira will create the issue with creator as their name. Later looking at the tickets is there any way to identify whether the ticket was created from email or the user manually created it. Thanks in advance
I think, it is not possible automatically. What about using a extra customfield? this way you can fill that new field, with the value you want: one for manually opened tickets, and another for email opened tickets. You can show or hide this field, and this would allow you to look for manually opened using jql (even it is not your first need :) )
For making it more visual, then you can use a bit of proggramatic magic and represent the values with icons or wahtever.
Let me know if it is not clear or if you need help for adding the new field or whatever.
Edit: the easiest way for doing this could be add to every issues opened by mail, at the begining of the summary something like "from mail:" and then the real summary. Anyway probably better if you customize the handler or create new one
Regards
My app has several events based on which a user gets an email notification. What's the best way to handle this from a software/database design perspective?
Here are two instances when I send out an email to a user:
Someone replies to their comment.
Someone likes their comment.
I also need a way for the user to turn these email events off individually in their user settings.
Here is what I'm thinking of doing (which doesn't feel like a good way):
Have a bunch of boolean fields in the user table that turn on or off each email notification (eg: is_send_email_replies, is_send_comment_likes).
The user can then turn these bool values on or off in their setting.
Is there a better more pragmatic way to handle this?
This is considered a typical user settings where you can save it as a Rails json field or use gems like rails-settings
So assuming you'll use rails-settings gem you can do it as follows:
class User < ActiveRecord::Base
has_settings :email_notifications
end
then you can set and get settings like this
user.settings(:email_notifications).comments = true
user.settings(:email_notifications).likes = false
user.settings(:email_notifications).comments
# => true
I suggest you watch Ryan Bates' Railscasts on activity (ep. #406) and then reading into the public-activity gem. That can be an elegant way to handle the events that send out notifications to users.
As for how you will store and deal with preferences, check out the Preferences gem As the description itself says: ...sometimes it's necessary if you want users to be able to disable things like e-mail notifications.
One way that I've handled this in the past is to have a separate model for the preferences and for the email type. The preferences table acts as sort of a many to many relationship between users and types where they can set there own preference.
The main advantage here is you can add as many email types as you want (over time) and you wont be clogging up your user model.
On my User's edit page I want users to be able to select from checkboxes what programming languages they know. I will give them about 15 to choose from. I then want to store these results in the User model to be accessed/searched for later.
What is the best way to go about this?
You can apply a many to many associations for achieving so. If you Google or even search SO, you will get lots of examples.
However, you can simply achieve same thing using the following gem
https://github.com/mbleigh/acts-as-taggable-on
It appears it's example matches your requirements. In the examples, they described same (skills) thing. So, you will get it done easily.
I have created a custom CMS Rails app for a local company, and had the request to allow the logo to be interchangeable for the holidays. For example, they talked about having choices of different logos for each holiday.
I am imaging a radio button looking something like this
Normal
Christmas
Christmas1
Easter
Easter1
Thanksgiving
4th of July
etc
So, does anyone have any idea how I would implement this, or have any experience with it?
I have an admin panel for them and I am thinking of adding a section that has the radio buttons mentioned above, and depending on what one is set a variable changes values and displays a different logo from the images folder, but not sure if that's the route to go.
Thanks for any help.
Edit: Sounds like I have the right idea, can I get some advice from you experts on how you would go about implementing this? I'm thinking of having a logo model where they can upload the image to, but how would I implement that into the view to allow them to pick?
Don't confuse two different things you will store in the database: the list of logos, and the setting of the current logo. The former will consist of a model and a table. The latter could be a simple foreign key pointing to the correct entry in that table.
You should also have a new controller since you plan to let them manage the list of logos. For image uploading check out Carrierwave which has comprehensive examples.