Ask HN: What do you want to see in Rails 4.1?
What can Rails add or change that will help your startup be even more great? How can we make Rails development more productive?
What can Rails add or change that will help your startup be even more great? How can we make Rails development more productive?
* Streamline the command line. Why rake to migrate, but rails to generate a migration? I know, I know. But new folks to Rails do not know. And it would be better if there was just one tool that does it all.
* Get rid of the global magic functions. users_path is nice and sweet, but where is it defined? Object? Kernel? Why can't I just call a method on my app. Sort of like how engines work: main_app.users_path is IMO better than users_path.
* I guess instance variables in views are a given forever, but I still don't like them. Why can't these be simple methods on objects as well? Simplify, simplify, simplify. Also, deprecate helpers. (Hey, I can dream!)
* I would help if my app was defined as a (singleton) class that I can see and use somewhere. It would be better if this were always a Gem, without me doing anything special. Then I could make all kinds of gem dependencies explicit.
* Fix mailers to allow them to work with async delivery out of the box. (Bringing back queues? Yes please!)
* Make mailers work with Markdown and friends to produce multipart emails out of the box. Write a pretty(ish) plaintext mail, and get HTML formatted for free. (There are gems for this, it would be nice if it were standard)
* Get rid of all hardcoded tokens in source code. Especially the session secret. Require dotenv gem and move all config into ENV. Including the database configuration!
* Fix the log file format. One line per event would be nice. Proper timestamps would be nice. Use standard Ruby loggers with a good format that the rest of the industry understands.
* Making apps no longer a singleton has been happening on master already, so expect to see a bunch of that.
* I like multipart emails too, since I prefer plaintext emails.
* Working on the tokens issue, I already commented about it elsewhere in this thread.
* As of Rails 4, you can slip in your own Logger, so this is pretty easy to customize if we don't change anything.
* Queues were explicitly brought back to 4.1, that's a feature that we (and I, maintaining Resque) really want to get in.
Thanks! <3
Hurray!
Better yet, make it as 12factor compliant as possible, out of the box.
I'm seeing more organizations learning towards frameworks like Ember.js and Angular.js. I'm also hearing lots of things like, "When I update the data in this browser, I want the changes to automatically propagate to other browsers."
Among other things, this means I need robust plugins like ember-rails that integrate into the asset pipeline and provide appropriate generators. I also need libraries similar to Socket.io that can notify the browsers when the model changes.
I don't necessarily want these features to be in the Rails 4.1 core. But I suspect that I'll be building more and more apps like this over the next two years, and I'd love to see Rails be a strong competitor on the back end.
* Improvement in performance in regarding to JSON generation or other thing is always welcome. following benchmarks can be taken as reference where rails stands currently. Any improvement in the above stats would be awesome http://www.techempower.com/benchmarks/#section=data-r6
As for JSON generation, there's an open ticket for it already: https://github.com/rails/rails/issues/9212
Oh yeah? I wonder if others would also pay for bug bounties.
As for getting it into core Rails, well, considering it was originally pulled out, I wouldn't hold your breath, as much as I'd prefer that personally.
The simplest answer is 'because nobody has written a pull request,' I don't believe anyone on the team actually uses websockets for anything, though I could be wrong.
In essence, the idea there should be an object that knows how to render a form based on an internal object state paired with a deserializer that knows how to read the form in and convert it to an internal object state. This way, by default, the form only recognizes the params that were defined and the risk of leaky params causing security issues is reduced by orders of magnitude.
I'm not sure how you retrofit something like this into Rails since it would be a huge architectural shift, but man it would be sweet to see something official along those lines.
With features like this, the usual answer is 'if a gem gets popular enough, we'll consider it.'
I'm not sure what concrete steps rails can take, but maybe app/lib for application specific code and lib/ for more generic libraries. Or maybe something less confusing.
[edit: rereading the parent, your reply was to where to put the code, and app/concerns is as good a place as any I guess, but I stand by the idea that concerns themselves are a bad idea.]
I think the message I would like to see communicated is that we as developers are free to create app/foo if we feel like foo is a good idea. Technically there's nothing stopping it. Culturally, it's almost unheard of.
I brought up lib/ because structurally it is a free for all. Nobody looks twice if I create lib/foo and add some code there. The problem is that I don't want to put app specific code into lib. I'm not sure if app/lib is a good idea, but I feel like it would communicate the idea that it is OK to write app specific code that doesn't fit into anything Rails has approved.
Anyway, I realize my concern is very much a culture issue. That culture has its pros and cons, and if we didn't have the strong opinion to stick to MVC, we would probably end up with a ton of spaghetti code in app/lib. I just wish we could strike the right balance.
https://github.com/ngauthier/tubesock is pretty close but it needs better support for channels. Basically, I want websocket-rails style auxiliary functions minus the custom controller part.
Some defaults for: queueing background jobs timers
Will come back at this tomorrow.
Thanks!
I'm personally very interested in the secret_token issue, and so is the rest of the team, but it's tricky to get the balance right. Working on it!
Are queues ready for prime-time yet?
Another vote for async mailers please - also sending more than one mail at once would be nice.
Sorting out secret_token.rb would be good - not sure what would work, ENV variable, auto-generating a file in production if not there, but there must be a better solution which lets you work both on Heroku and let's people avoid having secrets stored in version control by default.
Also, I know this has been a really thorny issue in the past, but the thing I add first to every single app I make is authorisation and authentication. Usually I use devise and cancan, but it'd be great to just have default rails generators for this - they could be very basic, just covering the most basic use-cases, and would obviously have to be optional. Not everyone would use them, but it would at least help a lot of beginners avoid mistakes like this:
https://www.computerworld.com/s/article/9186579/Facebook_wan...
and it would also provide guidelines for people on how to approach those topics - at present they'll tend to google a solution. That would help to emphasise that you need both of these things separately, and give us a baseline from which more complex bespoke solutions could easily be built.
The secret_token issue is one I'm personally interested in, we've been talking about the best way to fix it.
Yeah, we already have has_secure_password, which helps with authentication, but you still end up adding gems for authorization. I'll give this some thought, thanks.
For me, my wish list would be:
- Down with helpers. Or, at least the ability to arbitrarily set them. Maybe push presenter as alternatives?
- Some native performance tuning/testing/reporting would be awesome. Gems like rack-mini-profiler and ruby-prof are great, but a near-native tool, opinionated at that, would be awesome.
- I personally love the decorator pattern that gems like Spree use. Unfortunately (and maybe this is my own failing), eval'ing filters/callbacks is a big pain.
- As mentioned in another comment, the env specific configuration provided by figaro is awesome and should be native in Rails. Specifically, it might be a welcome alternative to the secret_token issue.
- Most deployment tools (Capistrano/Mina) enforce a different folder structure. It might be helpful to include some of them by default, or provide configurable options/symlinks that will work out of the box.
I have a lot more items on my list but those are the top items that I can think of at the moment.
I'm sure you know that I'm a big fan of presenters, maintaining one of the most popular gems that implements them, but they've generally been deemed a bit too heavy of a pattern in the past. What do you mean by 'arbitrarily set them'?
There were performance tests, but nobody used them, so we pulled them out to a gem in 4.0.
Can you give me an example of the eval problem? Not familliar with it.
For point one, I mean that developers have free range with helper definitions and that they eventually find their way into controllers.
Interesting news about performance tests in <4. I didn't realize that, I'll check them out.
The eval problem is as follows (typically if you have to eval something in a gem):
class Foo < ActiveRecord::Base
before_save :bar
..
end
Foo.class_eval do
# I want to remove before_save callback here without having to redefine it.
before_save :bar
...
def bar
return
end
end
It's not a big deal, just adds clutter. Thanks again!That said, other than increased usage, I don't think being included in core would actually do anything that we can't already do ourselves outside of core.
1. unify people who are looking for a standard approach to create api in Rails
2. clear separation between lower level http support and higher level html/js/css processing
3. performance improvement against using regular Rails for api
4. easier upgrade for app developers
- Something like spring ( https://github.com/jonleighton/spring ) built in because I use a low end machine and it still takes 5-6 seconds just to see a page refresh with live reloading enabled in my browser with nearly an empty project in terms of complexity. It would be nice to have it somehow work for tests and near instant code reloads for development.
Random question on queues: Will they be just as good (easy to use / efficient) as resque?
Queues will be an interface for things like Resque to implement, not an implementation itself. I maintain Resque too, it'll be a good story to use the two together.
I vaguely remember reading about a downside when using the console to run tests, maybe I should give it a second look.
All I care about is being able to run tests on file save from my editor and seeing feedback in a terminal window. Speedier the better of course.
It's a very nice gem for some use cases but a terrible default.
2) How is it not agnostic now? What's the problem with just using rspec?
Because ActiveSupport::Testcase is extension of Minitest. Thus, rspec won't be able to use all helpers of AS. I am fully aware of there are rspec-rails with equivalent matchers.
Sadly, majority of commercial companies are now using rspec/rspec-rails for the dev job, this makes AS::TS a second-class citizen. So if we could not abstractify AS::TS, my vote is to extract it to a separate gem and let user choose the test framework they want.