hanami / hanami.github.io Goto Github PK
View Code? Open in Web Editor NEWHanami website
Home Page: https://hanamirb.org
Hanami website
Home Page: https://hanamirb.org
Examples:
Without bundle exec
hanami generate action web dashboard#index
http://hanamirb.org/guides/actions/overview/
With and without lead percent
http://hanamirb.org/guides/projects/rake/
I suppose bundle exec is excess. With rbenv and one version of hanami it works properly without bundle exec. OhMyZsh with some simple settings adds bundle exec to rake commands automatically.
Perhaps these guides are not responsible with bundler and it needs to be moved to Command Line section.
The guides simply say:
If we want to mount an application, we should use mount.
It would be helpful to specify that the mount
instruction should go to config/environment.rb
.
Right before the section in the GS guide called "Building Forms To Create Records", there's some test output shown:
9 runs, 16 assertions, 0 failures, 0 errors, 0 skips
This test output has changed in v1.2 to:
12 runs, 20 assertions, 0 failures, 0 errors, 0 skips
I guess there have been some new tests added in the interim?
I am submitting this as an issue and not a PR because I couldn't find a 1.2-specific getting started guide at the moment.
Hi there,
I have an idea for restructuring the guides into their own respective repos.
For example, rather than having the assets
guides in this repo (hanami/hanami.github.io
) at source/guides/assets/
, we could put the guides inside the hanami/assets
repo, at guides/
Then the build tool here could just clone each of the repos and build the site based on that. Travis could listen to each repo for commits and rebuild the site for every one, to ensure it's up-to-date.
Here's the current sources/guides
folder, and where they'd be relocated to (/guides
in each repo unless specified):
actions/ => hanami/controller
architectures/ => hanami/hanami (guides/architectures)
command-line/ => hanami/hanami (guides/command-line)
helpers/ => hanami/helpers
mailers/ => hanami/mailer
models/ => hanami/model (guides/)
upgrade-notes/ => hanami/hanami (guides/upgrade-notes) - or stays here
applications/ => hanami/hanami (guides/applications)
assets/ => hanami/assets
getting-started.md => hanami/hanami (or stays here)
index.md => stays here
migrations/ => hanami/model (guides/migrations)
routing/ => hanami/router
views/ => hanami/view
This would fix the issue of having to make two separate PR's for changes that affect the guides. Though you'd still have to do that for changes that affect the getting-started
guide. The blog would stay in this repo.
This would also help people searching for something in, let's say, hanami/controller
that is answered in the guide for that section.
Thoughts?
@hanami/core-team @hanami/contributors
As from the section of the getting started page working-with-entities
For now, we want it to carry title and author information. Let's add these attributes.
# lib/bookshelf/entities/book.rb
class Book < Hanami::Entity
end
The text implies that readers should add attributes which I suppose is not true.
Reduce the width of your browser until you see the dropdown (or browse to the getting started guide on your phone).
Then select a topic from the dropdown.
Correct page shows but dropdown still shows 'Getting started'
Following the example in Custom Helpers Guide (http://lotusrb.org/guides/helpers/custom-helpers/), I had an application loading error:
uninitialized constant Web::Helpers (NameError)
with Lotus v0.5.0 and Ruby 2.2.3.
It seems to be related to the loading order defined in application.rb file:
# apps/web/application.rb
# ...
load_paths << [
'controllers',
'views',
'helpers'
]
# ...
view.prepare do
include Lotus::Helpers
include Web::Helpers::Shuffler
end
I guess helpers must be loaded before views before being included into them.
Inserting 'helpers'
on top of load_paths
fixed the issue:
# apps/web/application.rb
# ...
load_paths << [
'helpers',
'controllers',
'views'
]
# ...
I this is right, could you fix the guide?
Thanks.
Rewrite the mission statement in the main guides page:
http://hanamirb.org/guides/
Ref: hanami/hanami#658
Since 1.0 there's #fields_for_collection
It's basically the same as #fields_for
for has_many
relationships or can be used for bulk updates/creations
There should be a guide on database configuration explaining where to put the database link and what it should look like with majorly used databases (sqlite, mysql, postgresql)
As from the Architectures page, there is a sentence said that
Indeed, by opening lib/bookshelf.rb, we find the Bookshelf module, which is the main namespace of our project.
From my workspace, I don't see Module Bookshelf
on such file. My lib/bookshelf.rb content is as follow
Hanami::Utils.require!("#{__dir__}/bookshelf")
Not sure if such text is still valid.
I was wondering what the license of your source is, more specifically the design and it's assets.
hanami new bookshelf --database=postgres
should just be
hanami new bookshelf
We don't use any advanced features of Postgres, and it makes the Getting Started guide more complicated. Some users may have to spend time installing Postgres (which can be a pain!) or dealing with authentication issues... all just to learn the basics of Hanami!
I think we should include a note telling users that we're using SQLite and that in a production app they should use Postgres or some other production-ready database (and show them it's easy to use postgres instead: hanami new bookshelf --database=postgres
)
I checked new crystal site design and found that they have excellent community page:
https://crystal-lang.org/community/
I think we can create something similar for hanami too. WDYT?
/cc @hanami/core
We should add a new page with repository query examples.
ILIKE
, IN
, etc);#exist?
If you want to see something special please, add comment with it
In certain part of documentation follow this link , .one is used and the reason is that it throws error if nothing found using limit, while making use of .one it will return nil.I think it must be a standard to use .one for all the queries where we use .limit.
http://hanamirb.org/guides/1.0/models/sql-queries/
In the above link under section limit, this can be added
See more informations here: https://discourse.hanamirb.org/t/select-clause-in-a-repository/396/2
I suggest discussing what we want to add to guides. I created a simple list with my ideas. If you have other ideas - let's discuss and update list ❤️
cc @hanami/core
The page header contains reference to Atom feed http://feeds.feedburner.com/hanamirb , but it does not exist.
I wrote this code my application and I run the bundle exec hanami s
so I got message uninitialized constant Web
.
I think Web
is not initialized when accept_json.rb
is loaded.
Below codes work well.
# apps/web/views/accept_json.rb
module Web
module Views
module AcceptJson
def self.included(view)
view.class_eval do
format :json
end
end
end
end
end
or
# apps/web/application.rb
module Web
class Application < Hanami::Application
configure do
# ...
view.prepare do
require_relative './views/accept_json'
include Web::Views::AcceptJson
end
end
end
end
The blog page only links to the 5 most recent posts: http://hanamirb.org/blog/
I couldn't find any other way to see older blog posts. I just searched google for what I was looking for).
It makes sense to only show 5 most recent by default, but others should be reachable.
We can either add pagination, or make an 'archive' index page that links to all the blog posts.
In the v1.1, we'll change the good practices for interactors:
#call
#call
can now take anything as parameters, except no parameters (so the minimum declaration is def call(*); end
and not def call; end
Old format (̀#call
without parameters) will still be working (I guess we'll deprecate it in v1.2?)
@hanami/core WDYT?
Hanami::Interactor
, in hanami/utils
is a very useful component.
We should consider adding a Guide to the website about how to use it (and the benefits of it).
Perhaps it could be an extension of the Getting Started
guide, working from the bookshelf
example.
There's no Hanami::Utils
section on the site, so not sure if that's worth adding.
Happy to help write/review this guide, if we choose to move forward with it.
I may have found mistake in http://hanamirb.org/guides/1.1/architecture/interactors/.
That page contain code above:
# spec/bookshelf/interactors/add_book_spec.rb:
require 'spec_helper'
describe AddBook do
let(:interactor) { AddBook.new }
it "succeeds" do
expect(interactor.call).to be_a_success
end
end
# lib/bookshelf/interactors/add_book.rb
require 'hanami/interactor'
class AddBook
include Hanami::Interactor
def initialize
# set up the object
end
def call(book_attributes)
# get it done
end
end
Copy and paste these codes, run bundle exec rake test, I saw an error like this:
1) Error:
AddBook#test_0001_succeeds:
ArgumentError: wrong number of arguments (given 0, expected 1)
/Users/hoge/work/myruby/hanami_practice/bookshelf/lib/bookshelf/interactors/add_book.rb:10:in `call'
/Users/hoge/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/hanami-utils-1.1.1/lib/hanami/interactor.rb:356:in `block in call'
Right now we use dotenv
in development
and test
environments, but not production. This issue has effected several people in the chat.
We should consider adding a guide for Environment variables. Specifically, explain how they're set in development
and test
, as well as offer some suggestions for how to set them in production (heroku config:set
,.env.production
combined with an entry in .gitignore
, or even .bashrc
).
We can talk about SERVE_STATIC_ASSETS
and APPNAME_SESSIONS_SECRET
there too.
Some time ago sqlite
was set to be default adapter. After that deploy on heroku doesn't work(since heroku doesn't support sqlite). Instruction should be updated to don't confuse newcomers which would see that it doesn't work
I've been going through the guide and I've hit several places where it seems to be out of date or otherwise wrong.
hanami new bookshelf --database=postgres
will generate a project which uses minitest, not rspec, but all the code examples use rspecfoo.should.match bar
syntax, which nowadays is not recommended. Some of the test examples just don't run at all (those that use must_equal
and co; there is also one random assert
, which of course also fails in an rspec context)I can try to fix some of these issues, although I would need some guidance as to whether to change the test examples to minitest (since that is the out-of-the-box default), or change them to expect
syntax, or whatever.
Hi folks:
I open this issue because when you navigate the guides from a mobile it's a little irritating when you click a link and then you have to scroll down again.
You can see a screenshot to see what is the first thing you see when enter in the guides:
I think we could have a select instead the list, what do you think?
The bundle
directory is quite large and takes a long time to clone down here in Kangaland. I would suggest removing this directory and instead relying on the Gemfile.lock
.
My concern with it being so huge is that it is a barrier-to-entry for new OSS contributors, who may also come from countries with slow internet connections.
WDYT?
Hi,
This is really a small issue, and maybe it's by even by design, but I find it really annoying that whenever I open a new page in /guides
, the focus goes to the search box on top, because I can't scroll with PageUp/PageDown right away. And if I scroll with the mouse, when I click on a link (typically on the right-hand side panel), it does not activate the link but removes the focus from the search box. Then I have to click again. And at least on Firefox, the search box, when it receives the focus, extends too much and pushes the top-right-hand links div down, pushing the whole page contents down, so that means that the link will move up after the first click.
I hope that makes sense.
The Getting Started guide has a confusing inconsistency here:
With our validations in place, we can limit our entity creation and redirection to cases where the incoming params are valid:
# apps/web/controllers/books/create.rb module Web::Controllers::Books class Create include Web::Action expose :book params do required(:book).schema do required(:title).filled(:str?) required(:author).filled(:str?) end end def call(params) if params.valid? @book = BookRepository.create(Book.new(params[:book])) redirect_to '/books' else self.status = 422 end end end endYou may have noticed that there isn't an
else
condition to thatif
statement.
What happens when params aren't valid?
The paragraph after the code says that there isn’t an else
condition, but there is one – it says self.status = 422
. There is no other nearby code block that the paragraph could be referring to.
When I look at the history of getting-started.md
, I see that commit 4f5f071 “Guides: explain the differences between #halt and #status=” created this inconsistency. That commit mainly edited the HTTP Status section of the Action Control Flow page, but edited two code blocks in Getting Started too. The else
condition was added without the following paragraph being updated.
I don’t know enough to suggest whether the else
condition should be removed or the paragraph after the code should be revised.
Hello,
I think that it'll be very helpful. Because it'll allow automatically update the site.
Related link:
https://iamstarkov.com/deploy-gh-pages-from-travis/
/cc @hanami/core-team
Ref: hanami/hanami#649
Here https://github.com/hanami/hanami.github.io/blob/build/source/guides/head/actions/sessions.md it says that
Custom storage technologies are autoloaded via require "rack/session/#{ adapter_name }".
However, when I create file with class Rack::Session::Foo
loadable by require 'rack/session/foo'
, it's not autoloaded and server complains about uninitialized constant. At the moment I just require it manualy at top of application.rb
, but the guide should probably be reworded somehow (not sure how).
I built a quick and dirty tool to check the broken links on our website.
This is the output:
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v060 Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v070 Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v080 Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v090 Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v100 Not Found
Visiting http://hanamirb.org/guides/head/validations/boolean-logic Not Found
Visiting http://hanamirb.org/guides/head/validations/custom-predicates Not Found
Visiting http://hanamirb.org/guides/head/validations/advanced-usage Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v070 Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v100 Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v100beta1 Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v090 Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v080 Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v060 Not Found
Visiting http://hanamirb.org/guides/architectures/container Not Found
Visiting http://hanamirb.org/guides/architectures/application Not Found
Given example maybe should be replaced by another one, not bound to form, because passing wrong params cause error
Add a book#test_0002_displays list of errors when params contains errors:
NameError: undefined local variable or method `form' for #<Hanami::View::Rendering::Scope:0x007fe0fa942e00>
Did you mean? fork
Error happens because template is rendering from Web::Views::Books::Create instead Web::Views::Books::New and Create view don't have form method
And this may be confusing, especially when passing tutorial in first time.
We can both understand if a specific presentational logic behaves correctly and/or assert if the rendered markup.
I feel like a) there's something missing at the end ("assert if the rendered markup is correct") or b) the sentence should be slightly different ("assert the contents of the rendered markup").
We already have a mini-guide for deploying to Heroku on the homepage, in a tab, but we should put this same information (with more explanation) into a Guide. Perhaps we should make it generic, but focus on Heroku, since it's a standard enough that we can help people.
The cause for this is that @sovetnik asked about a deploying issue in the Gitter chat. We should make it so people don't have to ask in the chat.
I think it's an important theme for guides. That's why I suggest to add this. We can use this SO question for example:
https://stackoverflow.com/questions/43080678/join-query-in-hanami-model
Reference to #343
Those are links to:
/guides/1.0/actions/rack-integration/
/guides/1.1/actions/rack-integration/
/guides/actions/rack-integration/
(which is same as 1.1 right now)I think we should just link to the last one. What do others think? @davydovanton @hanami/core
Just started at https://github.com/translation-gang/ru.hanami.github.io
Primary maintainer is @sovetnik.
I'm doing the getting started tutorial:
http://lotusrb.org/guides/getting-started/
But I'm stuck here:
It seems that if there's no trailing slash on /books
, it says "File not found":
By adding the trailing slash, it displays correctly:
So I had to change visit
to use trailing slash in order to make the tests pass.
Any ideas why this is happening?
We have a little problem with travis now. For fixing this, I see two ways:
What do you prefer @hanami/core?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.