how do I write a scaffold in rails? - ruby-on-rails

I want to write a rails gem that can scaffold a working prototype of the basic functionality of the gem and I was wondering if anyone can explain the process. I know this is a broad topic but I'm hoping for some pointers to tutorials or other rails docs.
Thanks!

Like most problems I try to solve with rails, there's already a great project that helps you create "starter apps" with rails. Rails Apps helps you create application templates that you can then use to generate starter apps. There are some great examples (i.e. devise + rspec + cucumber) to get you started.

Related

Which is the best way to create a login in Rails for a starter?

I've seen there're several engines and tutorials about it, but I couldn't figure out which one could help me out in short terms. I'm just learning Rails and Ruby and my aim is to understand how it works while it can be useful in a real life event.
Any link or explanation about this will be kindly appreciated!
Other answers are recommending Devise. Devise's own documentation says:
If you are building your first Rails application, we recommend you to not use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch.
I'm inclined to agree. Devise is a great engine that can create a powerful login system for you in minimal time, but if you're building an app for the purpose of learning Rails, I'd recommend following a tutorial to build your own login system so you get a deeper understanding of what's actually going on beneath the hood. You can always come back and use Devise later.
For a tutorial, I'd recommend the same book that Devise recommend, Michael Hartl's Ruby on Rails Tutorial - specifically chapters 6, 7, 8. (Well, I'd recommend the whole book, but those are the chapters that pertain to building a login system.)
If screencasts are more your thing, Ryan Bates's Railscast on the subject
is supposed to be good although I haven't watched it myself.
a gem called devise, as simple as install it and minimal configuration
https://github.com/plataformatec/devise
add it to gem file:
gemfile.rb
gem 'devise'
install :
rails generate devise:install
create User model:
rails generate devise user
and here are the commands you can use:
https://github.com/plataformatec/devise#controller-filters-and-helpers

Rails app to engine

How we can convert a existing rails app(3.2.11) into a engine. We have some defined functionality in our rails app and we want to use this rails app functionality as engine so that we can add/share/mount this functionality with other rails app.
Do we have any available gem or any idea for this.
Thanks in advance!!
We have recently started doing this at my company and we will never look back. Engine gems are great for using the same logic across multiple projects.
That said, start with this railscast: Mountable Engines (I think this is the right link, it is blocked here at work so I can't verify for sure. If it's not then just google "railscasts engines.")
Also, check out the documentation here.
This is where we started and we released our engine in no time.

Implementing a chat application in Ruby on Rails

Basically, the app has to support sign up/sign in functionality and allow user to add friends and allow friends to chat.Since, I am just starting? with rails it's a bit overwhelming. How should I go about it
Also, the aim is not an application for production.
It'll be great if you could link to some working demos of the same.
Thanks!
If you are learning rails there are lots of great resources online. Try googling for a few.
I would suggest Michael Hartl's Rails Tutorial - http://ruby.railstutorial.org/ruby-on-rails-tutorial-book - it includes bits of what you want.
You would need ofcourse to read tutorials for rails beginners, I recommend the official rails guide.
For sign up/sign in, you could use the devise gem, and for chat push you could take a look at private_pub gem.
You can also check out a tutorial I did on how to achieve the same using devise and private_pub gem. I believe this should get you started http://goo.gl/l3e8zN

Rails: Trying to separate a model into an engine gem

I'm new to here an to Rails so excuse any dumbness on my part.
I'm trying to do something really simple and can't seen to find a guide that's up to date and properly demonstrates how to do this.
I've written the app described in the official ruby on rails tutorial:
http://edgeguides.rubyonrails.org/getting_started.html
Now I want to take one of the models, say Tags and make a gem out of that. How would I achieve this? I've read some on rails Engines but couldn't really figure out what goes where and mostly what the generators would look like.
I want to be able to write another app now, such as something flickr styled and by adding the new Tags gem to the Gemfile and having a
:has_many tags
In the picture model I've added a tags mechanism to all my pictures.
Any help would be greatly appreciated!
Welcome! Glad you liked the getting started guide, I then shall guide you to the (yet unreleased) engines guide.

Embed Blog in Ruby on Rails

I have a Ruby on Rails application and want to include a blog inside the application.
I was wondering what's the best way to do that. I don't want to have a link to an external blog. I want the blog integrated in my application. Also i don't have the time to programm the blog functionality. I want to use existing solutions.
What's the best way to accomplish that? Any recommendations? What are the best solutions?
The best way to include one application within another is by using engines. This might help you Ruby on Rails 3.1 Blog Engines
Perhaps Typo would address your needs installed as a Rails Engine.
Since nobody has done it so far I need to mention here that the spirit of Rails is to make everything friendly enough so that you can code your own.
It's a bit more work but then your blog module fits right in with the rest of the app.

Resources