RoR 3 Aproval on records - ruby-on-rails

I have an blog where anyone can comment. I would like to approve the comments before they are published. I have a boolean field named "published" and I'm unsure what to do next. Can anyone point me in the right direction?

I can imagine several features :
you need to be be notified when a comment is created. If you're not expecting too much traffic, the application can notify you by email with the ActionMailer
you need an admin page where you'll see all the comments that are waiting from your approval. Use filters to ensure that only you have access to this page.
you'll certainly need to see the comments "in situ" before approving them. The blog page should display only "published" comments for average user, but for you it should display all comments, with a button to publish the ones waiting for approval.

Related

Can i make a website without an user login

I'm planning to make a simple one page or two page website on travel experience. Guests can sent me those details by form and I can post it on website.
The short answer is, yes you can.
From what I understand you want any visitor to your site to be able to type up a travel experience on the site, submit it, you then moderate and check it, and decide to publish it or not.
As much as that describes a "simple one or two page website", there is a lot that needs to happen for you to accomplish that:
You will need a database to store the user submissions in;
You probably want some kind of protection mechanism so that a malicious user or bot cannot just submit millions of rubbish entries;
You will want to send commands to your database in a way that prevents "SQL Injection" whereby a user can hide malicious actions (like deleting all your data in the database) inside his submission.
I can carry on, but I think you get the point: what you want to do is a simple technical exercise for someone who already knows how to build dynamic websites, but quite a challenge for someone with little or no experience.
That does not mean that it won't be a worthwhile exercise and a most valuable learning experience, but it won't be a quick couple of days' work for someone without the experience and knowledge.
There are tons of free resources on the web that you can use to learn to do exactly what you envision, so I encourage you to go for it. Good luck!
They are no need of the user login to send Posts to you. You can simply design a Submit Post page and get the Posts under your view. After that you can Publish or reject the submitted posts.
But there are some problems,
You can not verify the users who are submitting the posts
Accuracy of the posts will be reduce due to unauthorized requests.

JIRA: Send issue comment notifications after grace period for edits

I'm subscribed to an issue in JIRA. Whenever someone comments on it, or changes a comment of his, I get an email.
Often this results in multiple consecutive emails, when people enter a comment, and then refine it multiple times.
I'd like to tell JIRA to wait after a new comment before sending me the notification mail, which should then include all modifications to it by the time.
Is this possible?
I know this question might be better off at superuser, but the jira tag here seems by far more frequented.
If I get you right, when somebody wanna edit his comment there is a tick asking if he wanna notify all the watchers about the edit with the email message or not.
So all you can do is to ask your team to leave comments with 'notify' tick disabled
You can actually disable this autosend notifications through the API from Jira, see documentation : https://confluence.atlassian.com/jira/configuring-email-notifications-185729575.html

Is there a way to setup permissions so that a viewer can only view issues he is monitoring

I have been given a requirement to allow our sales team to view all of the issues that we are in the process of investigating/fixing that their customers are experiencing.
We've added a custom column that contains a list of all of our customers so that we can filter by customer.
We are going to add viewer accounts for everyone on our sales team.
On every issue we were going to add the relevant sales guy as a viewer. That way the sales guy will get an email whenever a customer's issue is resolved, moved to feedback, etc.
Here is the question:
We want the sales guy to be able to log into Mantis and on his "View Issues" page have a filter already setup that displays all of the issues he is monitoring, and only his issues (to avoid confusion). Is that possible?
We don't really care if he can see all of the resolved issues, unassigned issues, recently modified, etc on the "my view" page. This isn't really a security thing, it is a usability thing. I want to be able to send a link to the sales guy and tell him to bookmark it and it will contain a continually updating list of the issues that pertain to him.
This may be a workable solution, but it is still a little clunky.
If I send out a URL like this:
<SERVER ADDRESS>/print_all_bug_page.php?filter=<XX>
Where the XX is the corresponds to the value of "myself" on the monitored by box. For me it is 52, not sure if that will change as I play with the columns.
Therefore the link right now is:
<SERVER ADDRESS>print_all_bug_page.php?filter=52
What's clunky is: If the user clicks any of the column headings on this page for sorting the query string isn't included in the new URL and all of the issues are then displayed again.

Rails 3 best way to create a comment system for posts

my first entry here.
I'm trying to add a comment system to our Posts model. However, I am not sure of the best way to go about it for a number of reasons. I'd like the comment system to be similar to that on Forrst.com but i'd rather have visitors who comment not need an account as the site is our company site not a large community.
Outline of features are:
Visitor can comment on post, entering name, email and comment.
Our team members can comment, i'd like these to be styled differently so would like the system to know it was from one of our team, they will be logged into the system when leaving a comment.
Visitors and team members can reply to a comment. The system needs to know which comment it was in reply to.
Lastly i'd like the system to know if the comment was written by the post author.
I have looked and been trying out acts_as_commentable_with_threading which seems perfect except everyone needs a user account to leave a comment, something I am trying to avoid unless anyone has other thoughts on that?
I have also implemented this myself by creating a comments model and using awesome_nested_set for the threading. Within the comments model I have a user_id which is only populated if the user is logged in (meaning they must be a team member), this seems a little messy though.
Does anyone have any thoughts on this?
Oh, and I would love each person to be notified of a reply to their comment (if pos).
Thanks in advance.
There are lot of tools available to post comments and working with ruby on rails.
http://ruby-toolbox.com/categories/rails_comments.html
also you can customize according your own requirement instead of writing a messy code.
If you do not want to integrate a third-party service like Disqus, you have Juvia The Comments and Commontator. Also you can count with opinio as alternative. but only with Rails 3 and at the moment and as notice the development seems stalled.

Rails - Create separate table or bypass all model validation?

I am currently using wepay with rails. Don't worry this post is nothing about wepay.
So when a customer wants to buy something from my site, he/she will be redirected to wepay.
Then after paying on wepay, wepay will redirect the user to /purchases/received
After X amount of time, Wepay will also do a post call to /purchases/callback to tell me that the payment has been captured (credit card processing is slow)
So my original plan is as follows:
For the Purchase model, have a field, wepay_id and wepay_confirmed.
When the user place an order on wepay, the redirection to /puchases/received will create a purchase instance and save in my db
When the callback is called look up by wepay_id and then set wepay_confirmed to true.
However, as I discovered that the X amount of time could be so fast that /purchases/callback is called before /purchases/received could create the object.
So now I have two options:
Allow /purchases/callback to create an empty Purchase instance with just the id and confirmed = true. As I was doing this, I realized that I no longer can validate my model in the traditional manner. This really bugs me.
Create a separate table called Wepay_Confirmed. Whenever callback is called, create an entry in wepay_confirmed. Map the presence of an (checkout_id) in this table to Purchase.confirmed attribute.
I am thinking of doing 2. How can I do this? Do I have to generate a scaffold for a specific model to map to Wepay_Confirmed?
If you have any other suggestions, please reply
I would try to keep your application the way it is because it does make sense however you should look into returning an error code to wepay and have them submit the request later after the record is created.
Just emailed the developers over at WePay and got this response:
Hi Devin,
We do have automatic IPN retries. Retries happen 5 minutes after the
initial try, if the retry doesn't work, we try 15 minutes later, and
then an hour later. However, right now they are only on empty 404
responses.
The best solution is to actually just ignore the IPN if he does not
have the record in his database. Our IPNs only tell an application to
look up the checkout details with the /checkout call. They do not have
any details of the checkout. Since he should be looking up the
/checkout status anyway when he creates the checkout object on his
end, he doesn't need the IPN to tell him to look up the status in this
case.
If that doesn't work for him he can also email me at api#wepay.com and
we may be able to work out a solution.
Andrew
So it looks like you can modify the flow of you application to ignore the IPN's without a record and check manually or you can respond with a 404 and they will retry at the above intervals.
As I mentioned in my comment, I would personally prefer to create the purchase record upon purchase, then send the user to the WePay site, then handle the return trip and callback as actions to be completed against that original purchase site.
For one, that matches the reality of the transaction more accurately. When a user makes a purchase from your site, it makes sense to me that it's something you should persist at that point.
The two elements of the WePay transaction (the return trip to your site and the charge confirmation callback) would all act on that original purchase record. This will also allow you to see how many people abandon the purchase process when they hit WePay, which could reveal issues in your user experience that might help to maximize conversions.
I created a gem called wepay-rails which handles all of this for you. Under the hood it creates the entry (WepayCheckoutRecord) before sending the payer off to wepay. It has an IPN listener built in that handles the updating of that record. In my personal rails app, I am using state machine on the WepayCheckoutRecord model to track the changes to the state and doing 'things' as the state changes on that record.
I hope that helps.
Adam -
If you take the 2nd approach, you dont need to scaffold it. You can just create a migration and use it inside one of your other 'scaffolds'. Scaffolds are really just a way to get started with a resource. I dont think your intent here is to have a fully-fledged resource. Unless it is then you can use it as a scaffold.

Resources