Flash for Sinatra - ruby

What’s the best way to go about using flash in Sinatra? Similar to how Rails or Flask handle flash.
The Sinatra docs suggest this gem, rack-flash for flash.
I also came across this gem, sinatra-flash for flash.
Is it best to use one of the above gems, a different gem, or implement it myself?
I was looking at how to use flash for displaying form validation errors.

Related

Ruby and databases

I am new in programming in Ruby, not to mention databases, so i would like a few pointers to my question. I have a few websites, where i gather information from users by a form, which they fill out (my websites are in Wordpress). The form is made in Contact Form 7 (https://wordpress.org/plugins/contact-form-7/) and the info is stored in the database with this plugin (https://wordpress.org/plugins/contact-form-7-to-database-extension/).
My question is: Is it possible to make a ruby program, that would fetch info from my sites (databases) and show me the information? Is there a better way of doing this (Ruby on rails perhaps)?
It is possible to access your wp data from a ruby app. You will need to familiarise yourself with the wordpress api. This gem might also help. You can build a small sinatra based app to keep it simple or use rails.

Can you integrate Shoes apps into Sinatra?

How would someone integrate a Shoes GUI with something like Sinatra? How does that work or is that not possible? Would I call for it instead of an erb file? Can shoes GUIs make get, put, post, and delete requests? Thanks.
You can use REST requests from any application, so obviously from Shoes as well. Take a look at the rest-client gem - it is a quick solution for a small clients. Or you may use Active Resource, the Active Record like approach.

User login/session system description

I'm building my first web app, and I've got all these crazy ideas on ways I could handle things like logins/sessions, but I was wondering if anyone has written a really good, thorough description of how logins/sessions work. I've seen tutorials, but I want to know if theres something more abstract that gives the reader a more general idea of how the whole process is handled. My web app is in ruby/sinatra if that's relevant.
Most of the in-depth tutorials for login/authentication from scratch are for Rails unfortunately. I went through the same trouble trying to find Sinatra specific tutorials. I would recommend just checking out the rails oriented tutorials since the knowledge is pretty general and can be applied to Sinatra as well.
These guides from RailsGuides are pretty good for getting an understanding of authentication even though they are Rails specific (read the section on security especially):
http://guides.rubyonrails.org/
Here's an example of a good Sinatra authentication scheme on github (it uses the datamapper gem, but you can easily replace this with any other Ruby ORM):
https://github.com/daddz/sinatra-dm-login
If you aren't as interested in rolling your own, you can also try the sinatra-authentication gem:
https://github.com/maxjustus/sinatra-authentication

OAuth2 Provider gem for non-rails, non-mongo apps?

I need to add OAuth2 authentication to a Sinatra-based API. No ActiveRecord, no MongoDB... but DataMapper.
Does anybody know what gems I can use to achieve this? I added rack-oauth2-server, but it depends on Mongo. I'm trying to understand rack-oauth2, but there is practically no documentation and I can't see how this is supposed to integrate in a real application that provides oauth authentication. Any well-documented gems out there? (Not Rails gems).
omniauth-oauth2 looked like it would work, but again, there's basically no documentation on how to integrate it. Links to articles that outline integration with these gems would also be useful.
I've been searching all day and just keep going around in circles. I'm sure this is a solved problem.
Why you didn't look at http://rubydoc.info/gems/oauth2/0.7.1/frames?

Mounting a sinatra app on rails 3.1 heroku

I'm trying to mount the following
https://github.com/cookinfacebook/fb-koala-heroku
Into a brand new Rails 3.1 app using sinatra, but i'm not sure how to do it.
Where would I put this in a Rails app and what would my route be?
Do I have to move the gems from the sinatra apps Gemfile to my facebook apps Gemfile?
I think that you have more reading to do. It looks like from the koala app template that you don't need Rails - and indeed it would likely add a lot more baggage and problems, since usually its Sinatra OR Rails.
Sinatra and Rails both run using the ruby programming language.
I hope that helps.

Resources